| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- //----------------------------------------------------------------
- //Module Name: $safeprojectname$
- //Purpose:
- //CopyRight: Muchinfo
- //History:
- //----------------------------------------------------------------
- //DateTime 2017/4/28 11:37:40
- //Author
- //Description Create
- //----------------------------------------------------------------
- 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.Helper;
- 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.MTPClient.Resources;
- using Muchinfo.PC.Common.Helpers;
- namespace Muchinfo.MTPClient.Bank.ViewModels
- {
- public class BindCardViewModel : ViewModelBase
- {
- /// <summary>
- /// 银行接口
- /// </summary>
- private IBankService _bankService;
- /// <summary>
- /// 签约信息
- /// </summary>
- private SigningBank _signingBank;
- #region 属性
- private string _bankAccountName;
- /// <summary>
- /// 银行账号名称
- /// </summary>
- public string BankAccountName
- {
- get { return _bankAccountName; }
- set { Set(() => BankAccountName, ref _bankAccountName, value); }
- }
- private string _bankCardNum;
- /// <summary>
- /// 银行卡号
- /// </summary>
- public string BankCardNum
- {
- get { return _bankCardNum; }
- set { Set(() => BankCardNum, ref _bankCardNum, value); }
- }
- public Dictionary<BankAccountType, string> AccountDictionary
- {
- get
- {
- var dicType = new Dictionary<BankAccountType, string>();
- dicType.Add(BankAccountType.PrivateAccount, BankAccountType.PrivateAccount.Discription());
- dicType.Add(BankAccountType.PublicAccount, BankAccountType.PublicAccount.Discription());
- return dicType;
- }
- }
- private Banks _selectBankItem;
- /// <summary>
- /// 选择银行
- /// </summary>
- public Banks SelectBankItem
- {
- get
- {
- return _selectBankItem;
- }
- set
- {
- Set(() => SelectBankItem, ref _selectBankItem, value);
- }
- }
- private bool _isBusy;
- public bool IsBusy
- {
- get { return _isBusy; }
- set { Set(() => IsBusy, ref _isBusy, value); }
- }
-
- private List<Banks> _bankList;
- /// <summary>
- /// 开户银行列表
- /// </summary>
- /// <value>The bank branch dictionary.</value>
- public List<Banks> BankList
- {
- get
- {
- return _bankList;
- }
- set
- {
- Set(() => BankList, ref _bankList, value);
- }
- }
- private BankAccountType _BankAccountType;
- /// <summary>
- /// 对公对私方式
- /// </summary>
- public BankAccountType BankAccountType
- {
- get { return _BankAccountType; }
- set { Set(() => BankAccountType, ref _BankAccountType, value); }
- }
-
- #endregion
- public BindCardViewModel(SigningBank signingBank)
- {
- _signingBank = signingBank;
- _bankService = SimpleIoc.Default.GetInstance<IBankService>();
- var accountid = UserManager.CurrentTradeAccount.AccountId;
- //if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
- //{
- // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
- //}
- _bankService.QueryCusBankParamConfig(accountid, QueryBankCusBankParamConfig, QueryErrorCallback);
- BankAccountName = signingBank.AccountName;
- BankAccountType = UserManager.CurrentTradeAccount.AccountType == eUserType.USERTYPE_INVESTOR
- ? BankAccountType.PrivateAccount
- : BankAccountType.PrivateAccount;
- }
- /// <summary>
- /// 查询托管银行信息配置
- /// </summary>
- /// <param name="list"></param>
- private void QueryBankCusBankParamConfig(List<CusBankInfo> list)
- {
- IsBusy = false;
- var cusBank= list.FirstOrDefault((item) => item.CusBankId == _signingBank.CusBankID);
- var queryCommons = new List<QueryCommonParam>();
- if (cusBank != null)
- {
- queryCommons.Add(new QueryCommonParam() { ParamKey = "bankid", ParamValue = cusBank.BankListId });
- }
- _bankService.QueryCommonBankInfo(queryCommons,QueryBankInfoCallback, QueryErrorCallback);
-
- }
- public void QueryBankInfoCallback(List<Banks> list)
- {
- IsBusy = false;
- BankList = list;
- if (list != null)
- {
- SelectBankItem = list.FirstOrDefault((item) => item.BankId == _signingBank.BankId);
- }
- }
- public void QueryErrorCallback(ErrorEntity error)
- {
- IsBusy = false;
-
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- ErrorManager.ShowReturnError(error, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Error, true);
- }));
- }
- private Window _view = null;
- public RelayCommand<Window> OKCommand
- {
- get
- {
- return new RelayCommand<Window>(
- (view) =>
- {
- if (Validate())
- {
- _view = view;
- IsBusy = true;
- _signingBank.RebindToNewBankCardNo = BankCardNum;
- _signingBank.RebindToNewBankCardNoAccName = BankAccountName;
- _signingBank.RebindToNewBankNo = SelectBankItem.BankId;
- _signingBank.BankAccountType = BankAccountType;
- _signingBank.ExtOperatorID = UserManager.CurrentTradeAccount.AccountId;
- _signingBank.AppDateTime = ApplicationParameter.ServerTimeNow.ToString("yyyy-MM-dd HH:mm");
- _signingBank.ExchId = UserManager.CurrentTradeAccount.ExchAreaId+string.Empty;
- _bankService.BankBindingBankCard(_signingBank, BankBindingCardSuccess, QueryErrorCallback);
- }
- });
- }
- }
- private void BankBindingCardSuccess(BankSignResult bankDealStatus)
- {
- IsBusy = false;
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- //switch (bankDealStatus.Status)
- //{
- // case BankDealStatus.BankDealStatus__Succeed:
- if (string.IsNullOrWhiteSpace(bankDealStatus.WebAddress))
- {
- MessageBoxHelper.ShowSuccess(
- Muchinfo.MTPClient.Resources.Client_Resource
- .Tips_BankReBindCardSuccess,
- Muchinfo.MTPClient.Resources.Client_Resource
- .APP_Tips);
- }
- // break;
- // case BankDealStatus.BankDealStatus__BankWebComfirm:
- else
- {
- try
- {
- IPHelper.OpenWebAddress(bankDealStatus.WebAddress);
- }
- catch (Exception ex)
- {
- throw new MuchinfoException(ExceptionManager.OpenIEError);
- }
- finally
- {
- var messageBox = new MsgAlter(bankDealStatus.WebAddress, Client_Resource.Tips_BankBindCardWebComfrim)
- {
- Owner = Application.Current.MainWindow,
- WindowStartupLocation = WindowStartupLocation.CenterOwner
- };
- messageBox.ShowDialog();
- }
- }
-
- // break;
- // }
- }));
-
- }
-
- private bool Validate()
- {
- if (SelectBankItem == null)
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_SelectBankAccount,
- Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
- return false;
- }
- if (string.IsNullOrWhiteSpace(BankAccountName))
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_InputAccountName, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
- return false;
- }
- if (string.IsNullOrWhiteSpace(BankCardNum)||!ValidationHelper.IsNumber(BankCardNum))
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_InputBankAccount, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
- return false;
- }
-
- return true;
- }
- }
- }
|