| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003 |
- using System.Windows;
- using GalaSoft.MvvmLight;
- using GalaSoft.MvvmLight.Command;
- using GalaSoft.MvvmLight.Ioc;
- using Muchinfo.MTPClient.Bank.Views;
- using Muchinfo.MTPClient.CustomException;
- using Muchinfo.MTPClient.Data;
- using Muchinfo.MTPClient.Data.Enums;
- using Muchinfo.MTPClient.Data.Extensions;
- using Muchinfo.MTPClient.Data.Model.Account;
- using Muchinfo.MTPClient.Data.Model.Bank;
- using Muchinfo.MTPClient.Infrastructure.Helpers;
- using Muchinfo.MTPClient.Infrastructure.MessageBox;
- using Muchinfo.MTPClient.Infrastructure.Utilities;
- using Muchinfo.MTPClient.IService;
- using Muchinfo.PC.Common.Extensions;
- using Muchinfo.PC.Common.Helpers;
- using Muchinfo.WPF.Controls.Windows;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Threading.Tasks;
- namespace Muchinfo.MTPClient.Bank.ViewModels
- {
- public class BankUpdateViewModel : IdentifyCodeTimerViewModel
- {
- #region 变量成员
- private IBankService _bankService;
- private BankUpdateView _view;
-
- private EncryptKey _encryptKey;
- private AreaAccount _areaAccount; //会员账号信息
- private bool _isBusy;
- /// <summary>
- /// 是否忙,显示等待控件
- /// </summary>
- public bool IsBusy
- {
- get { return _isBusy; }
- set { Set(() => IsBusy, ref _isBusy, value); }
- }
- private string _busyContent;
- public string BusyContent
- {
- get { return _busyContent; }
- set { Set(() => BusyContent, ref _busyContent, value); }
- }
- ///<summary>
- ///证件类型
- ///</summary>
- public Dictionary<eCardType, string> ClientCardTypes
- {
- get
- {
- //var types = new Dictionary<ClientCardType, string> { { ClientCardType.Id, ClientCardType.Id.Discription() }, { ClientCardType.Driver, ClientCardType.Driver.Discription() } };
- //return types;
- return EnumExtensions.ToDictionary<eCardType>();
- }
- }
- #region 确认银行账号
- private string _BankAccountConfirm = string.Empty;
- /// <summary>
- /// 确认银行账号
- /// </summary>
- public string BankAccountConfirm
- {
- get
- {
- return _BankAccountConfirm;
- }
- set
- {
- Set(() => BankAccountConfirm, ref _BankAccountConfirm, value);
- }
- }
- #endregion
- /// <summary>
- /// 银行列表数据源
- /// </summary>
- private List<Banks> BankListSource=new List<Banks>();
- private ObservableCollection<Banks> _bankList;
- /// <summary>
- /// 开户银行列表
- /// </summary>
- /// <value>The bank branch dictionary.</value>
- public ObservableCollection<Banks> BankList
- {
- get
- {
- return _bankList;
- }
- set
- {
- Set(() => BankList, ref _bankList, value);
- }
- }
- private Banks _selectBankItem;
- /// <summary>
- /// 选择银行
- /// </summary>
- public Banks SelectBankItem
- {
- get
- {
- return _selectBankItem;
- }
- set
- {
- Set(() => SelectBankItem, ref _selectBankItem, value);
- if (value != null)
- {
- CurrentSigningBank.BankId = value.BankId;
- CurrentSigningBank.Name = value.BankName;
- }
- }
- }
- //private List<SigningBank> _cusBankList = new List<SigningBank>();
- ///// <summary>
- ///// 签约的托管银行
- ///// </summary>
- //public List<SigningBank> CusBankList
- //{
- // get { return _cusBankList; }
- // set { Set(() => CusBankList, ref _cusBankList, value); }
- //}
- //private SigningBank _currentCusBank;
- ///// <summary>
- ///// 当前选中的托管银行
- ///// </summary>
- //public SigningBank CurrentCusBank
- //{
- // get { return _currentCusBank; }
- // set
- // {
- // Set(() => CurrentCusBank, ref _currentCusBank, value);
- // if (value != null)
- // {
- // CurrentSigningBank = SignBankList.FirstOrDefault(m => m.CusBankID == value.CusBankID);
- // }
- // }
- //}
- private ObservableCollection<SigningBank> _signBankList;
- /// <summary>
- /// 客户签约银行列表
- /// </summary>
- public ObservableCollection<SigningBank> SignBankList
- {
- get { return _signBankList; }
- set { Set(() => SignBankList, ref _signBankList, value); }
- }
- private List<CusBankInfo> _cusBankInfo;
- /// <summary>
- /// 托管银行信息
- /// </summary>
- public List<CusBankInfo> CusBankInfo
- {
- get { return _cusBankInfo; }
- set { _cusBankInfo = value; }
- }
- #region 变更后银行信息
- private SigningBank _newSigningBank = new SigningBank();
- /// <summary>
- /// Sets and gets the NewSigningBank property.
- /// </summary>
- public SigningBank NewSigningBank
- {
- get
- {
- return _newSigningBank;
- }
- set
- {
- Set(() => NewSigningBank, ref _newSigningBank, value);
- }
- }
- #endregion
- private SigningBank _currentSigningBank;
- /// <summary>
- /// 当前选中签约银行
- /// </summary>
- public SigningBank CurrentSigningBank
- {
- get
- {
- return _currentSigningBank;
- }
- set
- {
- Set(() => CurrentSigningBank, ref _currentSigningBank, value);
- //银行Id获取银行支行列表
- //Dictionary<string, string> BankBranchDictionary = _bankService.GetBankBranchList(value.Id);
- //支行Id获取支行名称
- //BranchName = BankBranchDictionary[value.BranchId];
- CredentialTypeName = ClientCardTypes[value.CredentialType];
- SetCollapsed();
-
- SetSignBankInfo();
- }
- }
- private string _credentialTypeName;
- /// <summary>
- /// 开户人证件类型名称
- /// </summary>
- public string CredentialTypeName
- {
- get
- {
- return _credentialTypeName;
- }
- set
- {
- Set(() => CredentialTypeName, ref _credentialTypeName, value);
- }
- }
- private string _branchName;
- /// <summary>
- /// 开户银行支行名称
- /// </summary>
- public string BranchName
- {
- get
- {
- return _branchName;
- }
- set
- {
- Set(() => BranchName, ref _branchName, value);
- }
- }
- /// <summary>
- /// 建行三方提示
- /// </summary>
- private bool _branchMessage = false;
- /// <summary>
- /// 建行三方提示
- /// </summary>
- public bool BranchMessage
- {
- get
- {
- return _branchMessage;
- }
- set
- {
- Set(() => BranchMessage, ref _branchMessage, value);
- }
- }
- /// <summary>
- /// 网银签约解约提示
- /// </summary>
- private bool _netMessage = false;
- /// <summary>
- /// 网银签约解约提示
- /// </summary>
- public bool NetMessage
- {
- get
- {
- return _netMessage;
- }
- set
- {
- Set(() => NetMessage, ref _netMessage, value);
- }
- }
- private string _netWorkSignTips;
- /// <summary>
- /// 网银端提示
- /// </summary>
- public string NetWorkSignTips
- {
- get { return _netWorkSignTips; }
- set
- {
- Set(() => NetWorkSignTips, ref _netWorkSignTips, value);
- }
- }
-
- /// <summary>
- /// 是否可点确定
- /// </summary>
- private bool _isOKEnable = true;
- /// <summary>
- /// 是否可点确定
- /// </summary>
- public bool IsOKEnable
- {
- get
- {
- return _isOKEnable;
- }
- set
- {
- Set(() => IsOKEnable, ref _isOKEnable, value);
- }
- }
- /// <summary>
- ///银行列表
- /// </summary>
- List<Banks> AccoumtBankSignList;
- #endregion
- #region 构造函数
- public BankUpdateViewModel(BankUpdateView view)
- {
- _view = view;
- IsBusy = true;
- temp_ankDealStatus = null;
- BusyContent = Muchinfo.MTPClient.Resources.Client_Resource.Bank_GetBankInfo_Waiting;
- _bankService = SimpleIoc.Default.GetInstance<IBankService>();
- // _bankService.QueryBankInfo(QueryBankInfoCallback, ErrorCallback);
- //todo: QueryBankCustomerSign 未返回CusBankName 先查询QueryCusBankInfo返回匹配该字段
- // SignBankList =
- //_bankService.QueryBankCustomerSign(QueryBankCustomerSignCallback, ErrorCallback);
- var accountid = UserManager.CurrentTradeAccount.AccountId;
- //if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
- //{
- // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
- //}
- _bankService.QueryBankCustomerSignInfo(accountid, SearchBankCustomerSignCallback, ErrorCallback);
- }
-
- /// <summary>
- /// 查询签约信息回应
- /// </summary>
- /// <param name="list"></param>
- private void SearchBankCustomerSignCallback(List<SigningBank> list)
- {
- IsBusy = false;
- if (ApplicationParameter.NewBankPlatform == 1) ////新银行平台
- {
- SignBankList = new ObservableCollection<SigningBank>(list);
- }
- else
- {
- SignBankList = new ObservableCollection<SigningBank>(list.Where((item) => item.ShowCancelSign == 0 && item.SignStatusType == SignStatus.SignStatus_Signed));
- }
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- if (SignBankList == null || SignBankList.Count <= 0)
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NoSignWithBank, Muchinfo.MTPClient.Resources.Client_Resource.APP_Tips);
- // BankUpdateView.Close();
- _view.Close();
- return;
- }
- CurrentSigningBank = SignBankList.FirstOrDefault();
- BankAccountConfirm = CurrentSigningBank.BankAccount;
- }));
- }
- private void QueryBankCustomerSignCallback(ObservableCollection<SigningBank> list)
- {
- IsBusy = false;
- SignBankList = new ObservableCollection<SigningBank>(list.Where((item) => item.ShowCancelSign == 0 && item.SignStatusType==SignStatus.SignStatus_Signed));
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- if (SignBankList == null || SignBankList.Count <= 0)
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NoSignWithBank, Muchinfo.MTPClient.Resources.Client_Resource.APP_Tips);
- // BankUpdateView.Close();
- _view.Close();
- return;
- }
- if (null != AccoumtBankSignList && AccoumtBankSignList.Any())
- {
- foreach (var item in SignBankList)
- {
- foreach (var k in AccoumtBankSignList)
- {
- if (item.BankId == k.BankId)
- {
- item.Name = k.BankName;
- // item.AccountName = UserManager.CurrentTradeAccount.CustomerName;
- }
- if (item.BranchId == k.BankId)
- {
- item.BranchBankName = k.BankName;
- }
- }
- }
- }
- CurrentSigningBank = SignBankList.FirstOrDefault();
- }));
- }
- #endregion
- public RelayCommand<BankUpdateView> OkCommand
- {
- get
- {
- return new RelayCommand<BankUpdateView>((win_BankUpdateView) =>
- {
- if (CurrentSigningBank == null)
- {
- return;
- }
- if (Validate())
- {
- IsBusy = true;
- BusyContent = Muchinfo.MTPClient.Resources.Client_Resource.Bank_SubmitChangeBankInfo_Wait;
-
- this.NewSigningBank.CusBankID = CurrentSigningBank.CusBankID;
- this.NewSigningBank.CustomerSignId = CurrentSigningBank.CustomerSignId;
- this.NewSigningBank.AccountName = CurrentSigningBank.AccountName;
- this.NewSigningBank.BankAccount = CurrentSigningBank.BankAccount;
- this.NewSigningBank.BankId = CurrentSigningBank.BankId;
- this.NewSigningBank.Name = CurrentSigningBank.Name;
- if (CurrentSigningBank.MobilePhone!="")
- this.NewSigningBank.MobilePhone = CurrentSigningBank.MobilePhone;
- NewSigningBank.ExtOperatorID = UserManager.CurrentTradeAccount.AccountId;
- NewSigningBank.AccountType = UserManager.CurrentTradeAccount.AccountType;
- NewSigningBank.AccountCode = UserManager.CurrentTradeAccount.AccountCode;
- _bankService.SignUpdate(NewSigningBank, SignUpdateCallback, ErrorCallback);
- }
- });
- }
-
- }
- /// <summary>
- /// 验证
- /// </summary>
- /// <returns>是否通过</returns>
- private bool Validate()
- {
- if (string.IsNullOrEmpty(CurrentSigningBank.BankAccount))
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_InputBankAccount, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
- return false;
- }
- if (string.IsNullOrEmpty(this.BankAccountConfirm))
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_ConfirmBankAccount, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
- return false;
- }
- if (this.CurrentSigningBank.BankAccount.Trim() != BankAccountConfirm)
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_InputBankAccountDifferent, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
- return false;
- }
- //if (this.NewBankAccount.Trim() == this.BankAccount.Trim())
- //{
- // MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NewAndOldAccountSame, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
- // return false;
- //}
- return true;
- }
- /// <summary>
- /// 取消
- /// </summary>
- public RelayCommand<BankUpdateView> CancelCommand
- {
- get
- {
- temp_ankDealStatus = null;
- return new RelayCommand<BankUpdateView>((win_BankUpdateView) =>
- {
- win_BankUpdateView.Close();
- });
- }
- }
- private void SignUpdateCallback(int result)
- {
- IsBusy = false;
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- if (result == 0)
- {
- MessageBoxHelper.ShowSuccess(Muchinfo.MTPClient.Resources.Client_Resource.Bank_ChangeBankInfoSuccess_Wait, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
- _view.Close();
- }
- else
- {
- ErrorManager.ShowReturnError(result, Muchinfo.MTPClient.Resources.Client_Resource.Bank_ErrotTips);
- }
- }));
- }
- private void SetCollapsed()
- {
- this.CurrentSigningBank.PaymentNumberVisibility = false;
- this.CurrentSigningBank.ProtocolNumberVisibility = false;
- this.CurrentSigningBank.MobilePhoneVisibility = false;
- //this.CurrentSigningBank.CertIDVisibility = false;
- //this.CurrentSigningBank.BankVisibility = false;
- //this.CurrentSigningBank.BranchVisibility = false;
- //this.CurrentSigningBank.BankBankAccountNoVisibility = false;
- //this.CurrentSigningBank.AccountNameVisibility = false;
- this.CurrentSigningBank.AgentNameVisibility = false;
- this.CurrentSigningBank.AgentCIDNumberVisibility = false;
- this.CurrentSigningBank.BankPasswordVisibility = false;
- this.CurrentSigningBank.DrawIdentifyCodeVisibility = false;
- if (!string.IsNullOrEmpty(CurrentSigningBank.ShowField))
- {
- bool isMemberTrade = UserManager.CurrentTradeAccount.AccountType !=
- eUserType.USERTYPE_INVESTOR;
- //根据当前所选签约银行,配置输入字段
- string[] SignShowField = this.CurrentSigningBank.ShowField.Split(',');
- foreach (string item in SignShowField)
- {
- switch (int.Parse(item))
- {
- case (int)ShowFieldStatus.ShowField_PaymentNo:
- this.CurrentSigningBank.PaymentNumberVisibility = true;
- break;
- case (int)ShowFieldStatus.ShowField_ProtocolNo:
- this.CurrentSigningBank.ProtocolNumberVisibility = true;
- break;
- //case (int)ShowFieldStatus.ShowField_CertID:
- // this.CurrentSigningBank.CertIDVisibility = Visibility.Visible;
- // break;
- //case (int)ShowFieldStatus.ShowField_Bank:
- // this.CurrentSigningBank.BankVisibility = Visibility.Visible;
- // break;
- //case (int)ShowFieldStatus.ShowField_BranchBank:
- // this.CurrentSigningBank.BranchVisibility = Visibility.Visible;
- // break;
- //case (int)ShowFieldStatus.ShowField_BankAccountNo:
- // this.CurrentSigningBank.BankBankAccountNoVisibility = Visibility.Visible;
- // break;
- //case (int)ShowFieldStatus.ShowField_AccountName:
- // this.CurrentSigningBank.AccountNameVisibility = Visibility.Visible;
- // break;
- case (int)ShowFieldStatus.ShowField_AgentCertID:
- this.CurrentSigningBank.AgentCIDNumberVisibility = isMemberTrade;
- break;
- case (int)ShowFieldStatus.ShowField_AgentName:
- this.CurrentSigningBank.AgentNameVisibility = isMemberTrade;
- break;
- case (int)ShowFieldStatus.ShowField_BankAccountPWD:
- this.CurrentSigningBank.BankPasswordVisibility = true;
- //todo获取银行密钥
- if (_encryptKey == null)
- {
- Task.Factory.TryStartNew(() =>
- {
- IsBusy = true;
- var reqkey = new EncryptKeyRequest()
- {
- Currency = (UserManager.CurrentTradeAccount.FundsAccounts == null || !UserManager.CurrentTradeAccount.FundsAccounts.Any())
- ? "RMB" : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency,
- CusBankId = CurrentSigningBank.CusBankID+string.Empty
- };
- // _encryptKey =
- _bankService.QueryEncryptKey(reqkey, QueryEncryptKeyCallback_ShowField_BankAccountPWD, ErrorCallback);
- }, () => IsBusy = false);
- }
- break;
- case (int)ShowFieldStatus.ShowField_Draw_IdentifyCode:
- this.CurrentSigningBank.DrawIdentifyCodeVisibility = true;
- //todo获取银行密钥
- if (_encryptKey == null)
- {
- Task.Factory.TryStartNew(() =>
- {
- IsBusy = true;
- var reqkeyIC = new EncryptKeyRequest()
- {
- Currency = (UserManager.CurrentTradeAccount.FundsAccounts == null || !UserManager.CurrentTradeAccount.FundsAccounts.Any())
- ? "RMB" : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency,
- CusBankId = CurrentSigningBank.CusBankID+string.Empty
- };
- //_encryptKey =
- _bankService.QueryEncryptKey(reqkeyIC, QueryEncryptKeyCallback_ShowField_Draw_IdentifyCode, ErrorCallback);
- }, () => IsBusy = false);
- }
- break;
- //case (int)ShowFieldStatus.ShowField_MobilePhone:
- // this.CurrentSigningBank.MobilePhoneVisibility = true;
- // break;
- }
- }
- }
- var BandIDList = ApplicationParameter.CusBankNetSign.Split(',');
- if (CurrentSigningBank.CusBankID == 2 )
- {
- this.BranchMessage = true;
- IsOKEnable = false;
- }
- else if (BandIDList.Contains(CurrentSigningBank.CusBankID + string.Empty))
- {
- this.NetMessage = true;
- this.NetWorkSignTips = ApplicationParameter.CusBankNetSignTipsInfo;
- IsOKEnable = false;
- }
- else
- {
- // this.BranchMessage = true;
- IsOKEnable = true;
- }
- }
- private void SetSignBankInfo()
- {
- IsBusy = true;
- BusyContent = Muchinfo.MTPClient.Resources.Client_Resource.Bank_GetBankInfomation_waiting;
- System.Threading.Tasks.Task.Factory.TryStartNew(
- () => System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- var accountid = UserManager.CurrentTradeAccount.AccountId;
- //if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
- //{
- // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
- //}
- _bankService.QueryCusBankParamConfig(accountid, QueryBankparamConfigCallback, ErrorCallback);
- })), () => IsBusy = false);
- }
- private void QueryBankparamConfigCallback(List<CusBankInfo> bankconfigs)
- {
- IsBusy = false;
-
- var bankConfig = bankconfigs.FirstOrDefault((item) => item.CusBankId == CurrentSigningBank.CusBankID);
- _cusBankInfo = bankconfigs;
- if (bankConfig != null && !string.IsNullOrEmpty(bankConfig.BankListId))
- {
- //根据配置字段过滤总行
- if (this.BankListSource == null || this.BankListSource.Count<=0)
- {
- var queryCommons = new List<QueryCommonParam>();
- _bankService.QueryCommonBankInfo(queryCommons, QueryBankInfoCallback, ErrorCallback);
- }
- else
- {
- SetbankListInfo(bankConfig);
- }
- }
- else
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_ChooseSignBankParameterSetError, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
- this.BankList = null;
- _view.bnt_OK.IsEnabled = false;
- }
- if (CurrentSigningBank.CusBankID == 2)
- {
- //this.BranchMessage = Visibility.Visible;
- _view.bnt_OK.IsEnabled = false;
- }
- }
- private void SetbankListInfo(CusBankInfo signingBank)
- {
- string[] bankListId = signingBank.BankListId.Split(',');
- List<Banks> bankList = new List<Banks>();
- foreach (string item in bankListId)
- {
- var bankId = item.Trim((@"\r\n").ToCharArray());
- Banks bank = this.BankListSource.FirstOrDefault(c => c.BankId == bankId);
- if (bank != null)
- {
- bankList.Add(bank);
- }
- }
- this.BankList = new ObservableCollection<Banks>(bankList);
- this.SelectBankItem = bankList.FirstOrDefault();
- _view.bnt_OK.IsEnabled = true;
- }
- private void QueryBankList()
- {
-
- var bankConfig = _cusBankInfo.FirstOrDefault((item) => item.CusBankId == CurrentSigningBank.CusBankID);
- //根据配置字段过滤总行
- if (bankConfig != null && !string.IsNullOrEmpty(bankConfig.BankListId))
- {
- var queryCommons = new List<QueryCommonParam>();
- if (this.BankListSource == null || BankListSource.Count() == 0)
- {
- _bankService.QueryCommonBankInfo(queryCommons,QueryBankInfoCallback, ErrorCallback);
- }
- else
- {
- string[] bankListId = bankConfig.BankListId.Split(',');
- List<Banks> bankList = new List<Banks>();
- foreach (string item in bankListId)
- {
- var bankId = item.Trim((@"\r\n").ToCharArray());
- Banks bank = this.BankListSource.FirstOrDefault(c => c.BankId == bankId);
- if (bank != null)
- {
- bankList.Add(bank);
- }
- }
- this.SelectBankItem = bankList.FirstOrDefault(x => x.BankId == CurrentSigningBank.BankId);
- this.BankList = new ObservableCollection<Banks>(bankList);
- _view.bnt_OK.IsEnabled = true;
- }
-
- }
- else
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_SignBank_ParameterError, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
- this.BankList = null;
- _view.bnt_OK.IsEnabled = false;
- }
-
- }
- public void QueryBankInfoCallback(List<Banks> list)
- {
- IsBusy = false;
- this.BankListSource = list;
- //this.BankList = new ObservableCollection<Banks>(list);
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- QueryBankList();
- //string[] bankListId = this.CurrentSigningBank.BankListId.Split(',');
- //List<Banks> bankList = new List<Banks>();
- //foreach (string item in bankListId)
- //{
- // var bankId = item.Trim((@"\r\n").ToCharArray());
- // Banks bank = this.BankListSource.FirstOrDefault(c => c.BankId == bankId);
- // if (bank != null)
- // {
- // bankList.Add(bank);
- // }
- //}
- //this.SelectBankItem = bankList.FirstOrDefault();
- //this.BankList = new ObservableCollection<Banks>(bankList);
- //_view.bnt_OK.IsEnabled = true;
- }));
- }
- private void QueryEncryptKeyCallback_ShowField_Draw_IdentifyCode(EncryptKey encryptKey)
- {
- if (String.IsNullOrEmpty(_encryptKey.SecretKey))
- {
- MessageBoxHelper.ShowQuestion(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NoGetIncryption, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Error);
- }
- }
- private void QueryEncryptKeyCallback_ShowField_BankAccountPWD(EncryptKey encryptKey)
- {
- if (String.IsNullOrEmpty(_encryptKey.SecretKey))
- {
- MessageBoxHelper.ShowQuestion(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NoGetIncryption, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Error);
- }
- }
- /// <summary>
- /// 临时结果
- /// </summary>
- private BankSignResult temp_ankDealStatus;
- public void BankCaneclSignCallback(BankSignResult bankDealStatus)
- {
- IsBusy = false;
- //一般情况银行电话密码和银行取款密码只需要一个
- bool isSendBankKey = (CurrentSigningBank.BankPasswordVisibility || CurrentSigningBank.DrawIdentifyCodeVisibility);
- temp_ankDealStatus = bankDealStatus;
- if (isSendBankKey && bankDealStatus.ReturnCode == 0)
- {
- var encryptHelper = new TasEncryptHelper();
- if (_encryptKey == null)
- {
- var reqkey = new EncryptKeyRequest()
- {
- Currency =
- (UserManager.CurrentTradeAccount.FundsAccounts == null ||
- !UserManager.CurrentTradeAccount.FundsAccounts.Any())
- ? "RMB"
- : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency,
- CusBankId = CurrentSigningBank.CusBankID+string.Empty
- };
- // _encryptKey =
- _bankService.QueryEncryptKey(reqkey, QueryEncryptKeyCallback, ErrorCallback);
- }
- else
- {
- string encryptPwd = "";
- if (CurrentSigningBank.BankPasswordVisibility)
- {
- encryptPwd = encryptHelper.EncryptPassd(_encryptKey.SecretKey,
- CurrentSigningBank.BankPassword);
- }
- else if (CurrentSigningBank.DrawIdentifyCodeVisibility)
- {
- encryptPwd = encryptHelper.EncryptPassd(_encryptKey.SecretKey,
- CurrentSigningBank.DrawIdentifyCode);
- }
- var req = new SignBankPDW()
- {
- AccountCode = UserManager.CurrentTradeAccount.AccountCode,
- ExchTicket = bankDealStatus.ExchTicket,
- ExtOperatorID = bankDealStatus.ExtOperatorID,
- CusBankId = CurrentSigningBank.CusBankID + string.Empty,
- BankAccountPWD = encryptPwd,
- Currency =
- (UserManager.CurrentTradeAccount.FundsAccounts == null ||
- !UserManager.CurrentTradeAccount.FundsAccounts.Any())
- ? "RMB"
- : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency
- };
- //errorCode =_bankService.SignBankPwd(req, UserManager.CurrentTradeAccount.LoginCode);
- _bankService.SignBankPwd(req, SignBankPwdCallback, ErrorCallback);
- }
- }
- SignBankPwdCallback(bankDealStatus.ReturnCode);
- }
- private void SignBankPwdCallback(int result)
- {
- var bankDealStatus = temp_ankDealStatus;
- bool isSendBankKey = (CurrentSigningBank.BankPasswordVisibility || CurrentSigningBank.DrawIdentifyCodeVisibility);
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- if (result == 0)
- {
- if (isSendBankKey)
- {
- MessageBoxHelper.ShowSuccess(
- Muchinfo.MTPClient.Resources.Client_Resource.Bank_TerminationSuccess,
- Muchinfo.MTPClient.Resources.Client_Resource.APP_Tips);
- if (bankDealStatus.Status == BankDealStatus.BankDealStatus__BankWebComfirm)
- {
- IPHelper.OpenWebAddress(bankDealStatus.WebAddress);
- var messageBox = new MsgAlter(bankDealStatus.WebAddress)
- {
- Owner = Application.Current.MainWindow,
- WindowStartupLocation = WindowStartupLocation.CenterOwner
- };
- messageBox.ShowDialog();
- }
- }
- else
- {
- // LogManager.WriteBankApplyLog(1, CurrentSigningBank, UserManager.CurrentTradeAccount);
- switch (bankDealStatus.Status)
- {
- case BankDealStatus.BankDealStatus__Succeed:
- MessageBoxHelper.ShowSuccess(
- Muchinfo.MTPClient.Resources.Client_Resource
- .Bank_TerminationSuccess,
- Muchinfo.MTPClient.Resources.Client_Resource
- .APP_Tips);
- break;
- case BankDealStatus.BankDealStatus__Pend:
- MessageBoxHelper.ShowSuccess(
- Muchinfo.MTPClient.Resources.Client_Resource
- .Bank_BankTerminationInfoSubmit_Wait,
- Muchinfo.MTPClient.Resources.Client_Resource
- .APP_Tips);
- break;
- case BankDealStatus.BankDealStatus__BankWebComfirm:
- try
- {
- IPHelper.OpenWebAddress(bankDealStatus.WebAddress);
- }
- catch (Exception)
- {
- throw new MuchinfoException(ExceptionManager.OpenIEError);
- }
- finally
- {
- var messageBox = new MsgAlter(bankDealStatus.WebAddress)
- {
- Owner = Application.Current.MainWindow,
- WindowStartupLocation = WindowStartupLocation.CenterOwner
- };
- messageBox.ShowDialog();
- }
- break;
- }
- }
- // win_BankUpdateView.DialogResult = true;
- _view.DialogResult = true;
- }
- else
- {
- ErrorManager.ShowReturnError(bankDealStatus.ReturnCode, Muchinfo.MTPClient.Resources.Client_Resource.Bank_ErrotTips);
- }
- //win_BankUpdateView.bnt_OK.IsEnabled = true;
- _view.bnt_OK.IsEnabled = true;
- }));
- }
- private void QueryEncryptKeyCallback(EncryptKey encryptKey)
- {
- var encryptHelper = new TasEncryptHelper();
- var bankDealStatus = temp_ankDealStatus;
- string encryptPwd = "";
- if (CurrentSigningBank.BankPasswordVisibility)
- {
- encryptPwd = encryptHelper.EncryptPassd(_encryptKey.SecretKey,
- CurrentSigningBank.BankPassword);
- }
- else if (CurrentSigningBank.DrawIdentifyCodeVisibility)
- {
- encryptPwd = encryptHelper.EncryptPassd(_encryptKey.SecretKey,
- CurrentSigningBank.DrawIdentifyCode);
- }
- var req = new SignBankPDW()
- {
- AccountCode = UserManager.CurrentTradeAccount.AccountCode,
- ExchTicket = bankDealStatus.ExchTicket,
- ExtOperatorID = bankDealStatus.ExtOperatorID,
- CusBankId = CurrentSigningBank.CusBankID + string.Empty,
- BankAccountPWD = encryptPwd,
- Currency =
- (UserManager.CurrentTradeAccount.FundsAccounts == null ||
- !UserManager.CurrentTradeAccount.FundsAccounts.Any())
- ? "RMB"
- : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency
- };
- //errorCode =_bankService.SignBankPwd(req, UserManager.CurrentTradeAccount.LoginCode);
- _bankService.SignBankPwd(req, SignBankPwdCallback, ErrorCallback);
- SignBankPwdCallback(bankDealStatus.ReturnCode);
- }
- public void ErrorCallback(ErrorEntity error)
- {
- IsBusy = false;
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- ErrorManager.ShowReturnError(error, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Error, true);
- }));
- }
- }
- }
|