| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- //----------------------------------------------------------------
- //Module Name: $safeprojectname$
- //Purpose:
- //CopyRight: Muchinfo
- //History:
- //----------------------------------------------------------------
- //DateTime 2017/3/14 18:33:26
- //Author
- //Description Create
- //----------------------------------------------------------------
- using System.Windows;
- 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.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 TerminationSignViewModel : IdentifyCodeTimerViewModel
- {
- private IBankService _bankService;
- private bool _isBusy;
-
- /// <summary>
- /// 是否忙,显示等待控件
- /// </summary>
- public bool IsBusy
- {
- get { return _isBusy; }
- set { Set(() => IsBusy, ref _isBusy, value); }
- }
- private SigningBank _currentSigningBank;
- /// <summary>
- /// 当前选中签约银行
- /// </summary>
- public SigningBank CurrentSigningBank
- {
- get
- {
- return _currentSigningBank;
- }
- set
- {
- Set(() => CurrentSigningBank, ref _currentSigningBank, value);
- }
- }
- private EncryptKey _encryptKey; ////银行密钥
-
- private string _password;
- /// <summary>
- /// 密码
- /// </summary>
- public string Password
- {
- get { return _password; }
- set { Set(() => Password, ref _password, value); }
- }
- public string[] ShowFielNo { get; set; }
- public TerminationSignViewModel(SigningBank SigningBank, string[] fieldNo)
- {
- CurrentSigningBank = SigningBank;
- ShowFielNo = fieldNo;
- _bankService = SimpleIoc.Default.GetInstance<IBankService>();
- if (IsBandPassWordVisible)
- {
- var reqkey = new EncryptKeyRequest()
- {
- Currency = (UserManager.CurrentTradeAccount.FundsAccounts == null
- || !UserManager.CurrentTradeAccount.FundsAccounts.Any())
- ? "RMB"
- : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency,
- CusBankId = CurrentSigningBank.CusBankID + string.Empty,
- };
- IsBusy = true;
- // _encryptKey =
- _bankService.QueryEncryptKey(reqkey, QueryEncryptKeyCallback_ShowField_BankAccountPWD,
- QueryErrorCallback);
- }
- }
- public bool IsBandPassWordVisible
- {
- get
- {
- if (ShowFielNo == null || !ShowFielNo.Any()) return false;
- return ShowFielNo.Contains(((int)ShowFieldStatus.ShowField_Draw_IdentifyCode) + string.Empty) || ShowFielNo.Contains(((int)ShowFieldStatus.ShowField_BankAccountPWD) + string.Empty);
- }
- }
- public bool IsMobileCodeVisible
- {
- get
- {
- if (ShowFielNo == null || !ShowFielNo.Any()) return false;
- return ShowFielNo.Contains(((int) ShowFieldStatus.ShowField_IdentifyCode) + string.Empty);
- }
- }
- private void QueryEncryptKeyCallback_ShowField_BankAccountPWD(EncryptKey encryptKey)
- {
- IsBusy = false;
- _encryptKey = encryptKey;
- if (String.IsNullOrEmpty(encryptKey.SecretKey))
- {
- MessageBoxHelper.ShowQuestion(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NoGetIncryption, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Error);
- }
- }
- public virtual void QueryErrorCallback(ErrorEntity errorEntity)
- {
- IsBusy = false;
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- ErrorManager.ShowReturnError(errorEntity, Client_Resource.APP_Tips, false);
- }));
- }
- public RelayCommand<Window> OkCommand
- {
- get
- {
-
- return new RelayCommand<Window>((view) =>
- {
- if (CurrentSigningBank == null)
- {
- return;
- }
- if (!Vailed())
- {
- return;
- }
- _view = view;
- var BandIDList = ApplicationParameter.CusBankNetSign.Split(',');
- if (this.CurrentSigningBank.CusBankID == 2)
- {
- MessageBoxHelper.ShowInfo(
- Muchinfo.MTPClient.Resources.Client_Resource.Bank_Termination_Message,
- Muchinfo.MTPClient.Resources.Client_Resource.APP_Tips);
- return;
- }
- else if (BandIDList.Contains(CurrentSigningBank.CusBankID + string.Empty))
- {
- MessageBoxHelper.ShowInfo(
- ApplicationParameter.CusBankNetSignTipsInfo,
- Muchinfo.MTPClient.Resources.Client_Resource.APP_Tips);
- }
- IsBusy = true;
-
- CurrentSigningBank.CurrentTime = ApplicationParameter.ServerTimeNow;
- CurrentSigningBank.ExtOperatorID = UserManager.CurrentTradeAccount.AccountId;
- //CurrentSigningBank.AccountCode = UserManager.CurrentTradeAccount.AccountCode;
- //CurrentSigningBank.CustomerName = UserManager.CurrentTradeAccount.CustomerName;
- CurrentSigningBank.AccountType = UserManager.CurrentTradeAccount.AccountType;
- //if (UserManager.CurrentTradeAccount.AccountType == eLoginUserType.LOGINUSERTYPE_TRADER &&
- // _areaAccount != null)
- //{
- //CurrentSigningBank.AccountCode = CurrentSigningBank.AccountCode;
- //CurrentSigningBank.CustomerName = CurrentSigningBank.CustomerName;
- // }
- _bankService.BankCaneclSign(CurrentSigningBank, BankCaneclSignCallback, ErrorCallback);
- });
- }
- }
- private Window _view;
- /// <summary>
- /// 临时结果
- /// </summary>
- private BankSignResult temp_ankDealStatus;
- public void BankCaneclSignCallback(BankSignResult bankDealStatus)
- {
- temp_ankDealStatus = bankDealStatus;
- IsBusy = false;
- //一般情况银行电话密码和银行取款密码只需要一个
- bool isSendBankKey = (IsBandPassWordVisible);
- temp_ankDealStatus = bankDealStatus;
- if (isSendBankKey && bankDealStatus.ReturnCode == 0)
- {
- var encryptHelper = new TasEncryptHelper();
- string encryptPwd = "";
- encryptPwd = encryptHelper.EncryptPassd(_encryptKey.SecretKey,Password);
- 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);
- return;
- }
- 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.Bank_BankTerminationTips);
- if (bankDealStatus.Status == BankDealStatus.BankDealStatus__BankWebComfirm)
- {
- IPHelper.OpenWebAddress(bankDealStatus.WebAddress);
- var messageBox = new MsgAlter(bankDealStatus.WebAddress, Client_Resource.Tips_BankUnSignWebComfrim)
- {
- 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
- .Bank_BankTerminationTips);
- break;
- case BankDealStatus.BankDealStatus__Pend:
- MessageBoxHelper.ShowSuccess(
- Muchinfo.MTPClient.Resources.Client_Resource
- .Bank_BankTerminationInfoSubmit_Wait,
- Muchinfo.MTPClient.Resources.Client_Resource
- .Bank_BankTerminationTips);
- break;
- case BankDealStatus.BankDealStatus__BankWebComfirm:
- try
- {
- IPHelper.OpenWebAddress(bankDealStatus.WebAddress);
- }
- catch (Exception)
- {
- throw new MuchinfoException(ExceptionManager.OpenIEError);
- }
- finally
- {
- var messageBox = new MsgAlter(bankDealStatus.WebAddress, Client_Resource.Tips_BankUnSignWebComfrim)
- {
- Owner = Application.Current.MainWindow,
- WindowStartupLocation = WindowStartupLocation.CenterOwner
- };
- messageBox.ShowDialog();
- }
- break;
- }
- }
- // win_BankTerminationView.DialogResult = true;
- _view.DialogResult = true;
- }
- else
- {
- ErrorManager.ShowReturnError(bankDealStatus.ReturnCode, Muchinfo.MTPClient.Resources.Client_Resource.Bank_ErrotTips);
- }
-
- }));
- }
- /// <summary>
- /// 取消
- /// </summary>
- public RelayCommand<Window> CancelCommand
- {
- get
- {
-
- return new RelayCommand<Window>((win_BankTerminationView) =>
- {
- win_BankTerminationView.Close();
- });
- }
- }
- /// <summary>
- /// 获取手机验证码
- /// </summary>
- public RelayCommand IdentifyCodeCommand
- {
- get
- {
- return new RelayCommand(() =>
- {
- if (CurrentSigningBank == null)
- {
- return;
- }
- var IndentityReq = new IdentifyCodeReq()
- {
- AccountCode = CurrentSigningBank.AccountCode,
- CusBankID = CurrentSigningBank.CusBankID + string.Empty,
- CustomerSignId = CurrentSigningBank.CustomerSignId,
- CustomerName = CurrentSigningBank.CustomerName,
- BankCode = CurrentSigningBank.BankId,
- AccountType = CurrentSigningBank.AccountType,
- BankAccountNo = CurrentSigningBank.BankAccount,
- CardNum = CurrentSigningBank.CredentialNumber,
- CardType = CurrentSigningBank.CredentialType,
- MobilePhone = CurrentSigningBank.MobilePhone,
- TradeType = BankTradeType.UpdateSign,
- Currency = (UserManager.CurrentTradeAccount.FundsAccounts == null || !UserManager.CurrentTradeAccount.FundsAccounts.Any())
- ? "RMB" : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency,
- };
- _bankService.BankGetIdentifyCode(IndentityReq, QueryIdentifyCodeSuccess, ErrorCallback);
- this.Start();
- });
- }
- }
- public void QueryIdentifyCodeSuccess(bool success)
- {
- }
- 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);
- }));
- }
- private bool Vailed()
- {
- if (IsMobileCodeVisible && string.IsNullOrEmpty(CurrentSigningBank.IdentifyCode))
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_InputIdentifyCode, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
- return false;
- }
- if (IsBandPassWordVisible && string.IsNullOrEmpty(Password))
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_InputBankPassword, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
- return false;
- }
- return true;
- }
- }
- }
|