BankTerminationViewModel.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  1. using System.Windows;
  2. using GalaSoft.MvvmLight;
  3. using GalaSoft.MvvmLight.Command;
  4. using GalaSoft.MvvmLight.Ioc;
  5. using Muchinfo.MTPClient.Bank.Views;
  6. using Muchinfo.MTPClient.CustomException;
  7. using Muchinfo.MTPClient.Data;
  8. using Muchinfo.MTPClient.Data.Enums;
  9. using Muchinfo.MTPClient.Data.Extensions;
  10. using Muchinfo.MTPClient.Data.Model.Account;
  11. using Muchinfo.MTPClient.Data.Model.Bank;
  12. using Muchinfo.MTPClient.Infrastructure.Helpers;
  13. using Muchinfo.MTPClient.Infrastructure.MessageBox;
  14. using Muchinfo.MTPClient.Infrastructure.Utilities;
  15. using Muchinfo.MTPClient.IService;
  16. using Muchinfo.MTPClient.Resources;
  17. using Muchinfo.PC.Common.Extensions;
  18. using Muchinfo.PC.Common.Helpers;
  19. using Muchinfo.WPF.Controls.Windows;
  20. using System;
  21. using System.Collections.Generic;
  22. using System.Collections.ObjectModel;
  23. using System.Linq;
  24. using System.Threading.Tasks;
  25. namespace Muchinfo.MTPClient.Bank.ViewModels
  26. {
  27. public class BankTerminationViewModel : IdentifyCodeTimerViewModel
  28. {
  29. #region 变量成员
  30. private IBankService _bankService;
  31. private BankTerminationView _view;
  32. private EncryptKey _encryptKey;
  33. private AreaAccount _areaAccount; //会员账号信息
  34. private bool _isBusy;
  35. /// <summary>
  36. /// 是否忙,显示等待控件
  37. /// </summary>
  38. public bool IsBusy
  39. {
  40. get { return _isBusy; }
  41. set { Set(() => IsBusy, ref _isBusy, value); }
  42. }
  43. private string _busyContent;
  44. public string BusyContent
  45. {
  46. get { return _busyContent; }
  47. set { Set(() => BusyContent, ref _busyContent, value); }
  48. }
  49. ///<summary>
  50. ///证件类型
  51. ///</summary>
  52. public Dictionary<eCardType, string> ClientCardTypes
  53. {
  54. get
  55. {
  56. //var types = new Dictionary<ClientCardType, string> { { ClientCardType.Id, ClientCardType.Id.Discription() }, { ClientCardType.Driver, ClientCardType.Driver.Discription() } };
  57. //return types;
  58. return EnumExtensions.ToDictionary<eCardType>();
  59. }
  60. }
  61. //private List<SigningBank> _cusBankList = new List<SigningBank>();
  62. ///// <summary>
  63. ///// 签约的托管银行
  64. ///// </summary>
  65. //public List<SigningBank> CusBankList
  66. //{
  67. // get { return _cusBankList; }
  68. // set { Set(() => CusBankList, ref _cusBankList, value); }
  69. //}
  70. //private SigningBank _currentCusBank;
  71. ///// <summary>
  72. ///// 当前选中的托管银行
  73. ///// </summary>
  74. //public SigningBank CurrentCusBank
  75. //{
  76. // get { return _currentCusBank; }
  77. // set
  78. // {
  79. // Set(() => CurrentCusBank, ref _currentCusBank, value);
  80. // if (value != null)
  81. // {
  82. // CurrentSigningBank = SignBankList.FirstOrDefault(m => m.CusBankID == value.CusBankID);
  83. // }
  84. // }
  85. //}
  86. private ObservableCollection<SigningBank> _signBankList;
  87. /// <summary>
  88. /// 客户签约银行列表
  89. /// </summary>
  90. public ObservableCollection<SigningBank> SignBankList
  91. {
  92. get { return _signBankList; }
  93. set { Set(() => SignBankList, ref _signBankList, value); }
  94. }
  95. private SigningBank _currentSigningBank;
  96. /// <summary>
  97. /// 当前选中签约银行
  98. /// </summary>
  99. public SigningBank CurrentSigningBank
  100. {
  101. get
  102. {
  103. return _currentSigningBank;
  104. }
  105. set
  106. {
  107. Set(() => CurrentSigningBank, ref _currentSigningBank, value);
  108. //银行Id获取银行支行列表
  109. //Dictionary<string, string> BankBranchDictionary = _bankService.GetBankBranchList(value.Id);
  110. //支行Id获取支行名称
  111. //BranchName = BankBranchDictionary[value.BranchId];
  112. CredentialTypeName = ClientCardTypes[value.CredentialType];
  113. SetCollapsed();
  114. // SetSignBankInfo();
  115. }
  116. }
  117. private string _credentialTypeName;
  118. /// <summary>
  119. /// 开户人证件类型名称
  120. /// </summary>
  121. public string CredentialTypeName
  122. {
  123. get
  124. {
  125. return _credentialTypeName;
  126. }
  127. set
  128. {
  129. Set(() => CredentialTypeName, ref _credentialTypeName, value);
  130. }
  131. }
  132. private string _branchName;
  133. /// <summary>
  134. /// 开户银行支行名称
  135. /// </summary>
  136. public string BranchName
  137. {
  138. get
  139. {
  140. return _branchName;
  141. }
  142. set
  143. {
  144. Set(() => BranchName, ref _branchName, value);
  145. }
  146. }
  147. /// <summary>
  148. /// 建行三方提示
  149. /// </summary>
  150. private bool _branchMessage = false;
  151. /// <summary>
  152. /// 建行三方提示
  153. /// </summary>
  154. public bool BranchMessage
  155. {
  156. get
  157. {
  158. return _branchMessage;
  159. }
  160. set
  161. {
  162. Set(() => BranchMessage, ref _branchMessage, value);
  163. }
  164. }
  165. /// <summary>
  166. /// 网银签约解约提示
  167. /// </summary>
  168. private bool _netMessage = false;
  169. /// <summary>
  170. /// 网银签约解约提示
  171. /// </summary>
  172. public bool NetMessage
  173. {
  174. get
  175. {
  176. return _netMessage;
  177. }
  178. set
  179. {
  180. Set(() => NetMessage, ref _netMessage, value);
  181. }
  182. }
  183. private string _netWorkSignTips;
  184. /// <summary>
  185. /// 网银端提示
  186. /// </summary>
  187. public string NetWorkSignTips
  188. {
  189. get { return _netWorkSignTips; }
  190. set
  191. {
  192. Set(() => NetWorkSignTips, ref _netWorkSignTips, value);
  193. }
  194. }
  195. /// <summary>
  196. /// 是否可点确定
  197. /// </summary>
  198. private bool _isOKEnable = true;
  199. /// <summary>
  200. /// 是否可点确定
  201. /// </summary>
  202. public bool IsOKEnable
  203. {
  204. get
  205. {
  206. return _isOKEnable;
  207. }
  208. set
  209. {
  210. Set(() => IsOKEnable, ref _isOKEnable, value);
  211. }
  212. }
  213. /// <summary>
  214. ///银行列表
  215. /// </summary>
  216. List<Banks> AccoumtBankSignList;
  217. #endregion
  218. #region 构造函数
  219. public BankTerminationViewModel(BankTerminationView bankTerminationView)
  220. {
  221. _view = bankTerminationView;
  222. IsBusy = true;
  223. temp_ankDealStatus = null;
  224. BusyContent = Muchinfo.MTPClient.Resources.Client_Resource.Bank_GetBankInfo_Waiting;
  225. _bankService = SimpleIoc.Default.GetInstance<IBankService>();
  226. // _bankService.QueryBankInfo(QueryBankInfoCallback, ErrorCallback);
  227. //todo: QueryBankCustomerSign 未返回CusBankName 先查询QueryCusBankInfo返回匹配该字段
  228. // SignBankList =
  229. //_bankService.QueryBankCustomerSign(QueryBankCustomerSignCallback, ErrorCallback);
  230. var accountid = UserManager.CurrentTradeAccount.AccountId;
  231. //if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
  232. //{
  233. // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
  234. //}
  235. _bankService.QueryBankCustomerSignInfo(accountid, SearchBankCustomerSignCallback, ErrorCallback);
  236. }
  237. /// <summary>
  238. /// 查询签约信息回应
  239. /// </summary>
  240. /// <param name="list"></param>
  241. private void SearchBankCustomerSignCallback(List<SigningBank> list)
  242. {
  243. IsBusy = false;
  244. if (ApplicationParameter.NewBankPlatform == 1) ////新银行平台
  245. {
  246. SignBankList = new ObservableCollection<SigningBank>(list);
  247. }
  248. else
  249. {
  250. SignBankList = new ObservableCollection<SigningBank>(list.Where((item) => item.ShowCancelSign == 0 && item.SignStatusType == SignStatus.SignStatus_Signed));
  251. }
  252. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  253. {
  254. if (SignBankList == null || SignBankList.Count <= 0)
  255. {
  256. MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NoSignWithBank, Muchinfo.MTPClient.Resources.Client_Resource.Bank_BankTerminationTips);
  257. // bankTerminationView.Close();
  258. _view.Close();
  259. return;
  260. }
  261. CurrentSigningBank = SignBankList.FirstOrDefault();
  262. }));
  263. }
  264. private void QueryBankCustomerSignCallback(ObservableCollection<SigningBank> list)
  265. {
  266. IsBusy = false;
  267. SignBankList = new ObservableCollection<SigningBank>(list.Where((item) => item.ShowCancelSign == 0 && item.SignStatusType==SignStatus.SignStatus_Signed));
  268. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  269. {
  270. if (SignBankList == null || SignBankList.Count <= 0)
  271. {
  272. MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NoSignWithBank, Muchinfo.MTPClient.Resources.Client_Resource.Bank_BankTerminationTips);
  273. // bankTerminationView.Close();
  274. _view.Close();
  275. return;
  276. }
  277. if (null != AccoumtBankSignList && AccoumtBankSignList.Any())
  278. {
  279. foreach (var item in SignBankList)
  280. {
  281. foreach (var k in AccoumtBankSignList)
  282. {
  283. if (item.BankId == k.BankId)
  284. {
  285. item.Name = k.BankName;
  286. // item.AccountName = UserManager.CurrentTradeAccount.CustomerName;
  287. }
  288. if (item.BranchId == k.BankId)
  289. {
  290. item.BranchBankName = k.BankName;
  291. }
  292. }
  293. }
  294. }
  295. CurrentSigningBank = SignBankList.FirstOrDefault();
  296. }));
  297. }
  298. #endregion
  299. public RelayCommand<BankTerminationView> OkCommand
  300. {
  301. get
  302. {
  303. temp_ankDealStatus = null;
  304. return new RelayCommand<BankTerminationView>((win_BankTerminationView) =>
  305. {
  306. if (CurrentSigningBank == null)
  307. {
  308. return;
  309. }
  310. var BandIDList = ApplicationParameter.CusBankNetSign.Split(',');
  311. if (this.CurrentSigningBank.CusBankID == 2)
  312. {
  313. MessageBoxHelper.ShowInfo(
  314. Muchinfo.MTPClient.Resources.Client_Resource.Bank_Termination_Message,
  315. Muchinfo.MTPClient.Resources.Client_Resource.APP_Tips);
  316. return;
  317. }
  318. else if (BandIDList.Contains(CurrentSigningBank.CusBankID + string.Empty))
  319. {
  320. MessageBoxHelper.ShowInfo(
  321. ApplicationParameter.CusBankNetSignTipsInfo,
  322. Muchinfo.MTPClient.Resources.Client_Resource.APP_Tips);
  323. }
  324. win_BankTerminationView.bnt_OK.IsEnabled = false;
  325. IsBusy = true;
  326. BusyContent = Muchinfo.MTPClient.Resources.Client_Resource.Bank_SubmitingTerminData_Wait;
  327. CurrentSigningBank.CurrentTime = ApplicationParameter.ServerTimeNow;
  328. CurrentSigningBank.ExtOperatorID = UserManager.CurrentTradeAccount.AccountId;
  329. //CurrentSigningBank.AccountCode = UserManager.CurrentTradeAccount.AccountCode;
  330. //CurrentSigningBank.CustomerName = UserManager.CurrentTradeAccount.CustomerName;
  331. CurrentSigningBank.AccountType = UserManager.CurrentTradeAccount.AccountType;
  332. //if (UserManager.CurrentTradeAccount.AccountType == eLoginUserType.LOGINUSERTYPE_TRADER &&
  333. // _areaAccount != null)
  334. //{
  335. //CurrentSigningBank.AccountCode = CurrentSigningBank.AccountCode;
  336. //CurrentSigningBank.CustomerName = CurrentSigningBank.CustomerName;
  337. // }
  338. _bankService.BankCaneclSign(CurrentSigningBank, BankCaneclSignCallback, ErrorCallback);
  339. });
  340. }
  341. }
  342. /// <summary>
  343. /// 取消
  344. /// </summary>
  345. public RelayCommand<BankTerminationView> CancelCommand
  346. {
  347. get
  348. {
  349. temp_ankDealStatus = null;
  350. return new RelayCommand<BankTerminationView>((win_BankTerminationView) =>
  351. {
  352. win_BankTerminationView.Close();
  353. });
  354. }
  355. }
  356. /// <summary>
  357. /// 获取手机验证码
  358. /// </summary>
  359. public RelayCommand IdentifyCodeCommand
  360. {
  361. get
  362. {
  363. return new RelayCommand(() =>
  364. {
  365. if (CurrentSigningBank == null)
  366. {
  367. return;
  368. }
  369. var IndentityReq = new IdentifyCodeReq()
  370. {
  371. AccountCode = CurrentSigningBank.AccountCode,
  372. CusBankID = CurrentSigningBank.CusBankID + string.Empty,
  373. CustomerSignId = CurrentSigningBank.CustomerSignId,
  374. CustomerName = CurrentSigningBank.CustomerName,
  375. BankCode = CurrentSigningBank.BankId,
  376. AccountType = CurrentSigningBank.AccountType,
  377. BankAccountNo = CurrentSigningBank.BankAccount,
  378. CardNum = CurrentSigningBank.CredentialNumber,
  379. CardType = CurrentSigningBank.CredentialType,
  380. MobilePhone = CurrentSigningBank.MobilePhone,
  381. Currency = (UserManager.CurrentTradeAccount.FundsAccounts == null || !UserManager.CurrentTradeAccount.FundsAccounts.Any())
  382. ? "RMB" : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency,
  383. };
  384. _bankService.BankGetIdentifyCode(IndentityReq, QueryIdentifyCodeSuccess, null);
  385. });
  386. }
  387. }
  388. public void QueryIdentifyCodeSuccess(bool success)
  389. {
  390. }
  391. private string _identifyCode;
  392. public string IdentifyCode
  393. {
  394. get { return _identifyCode; }
  395. set { Set(() => IdentifyCode, ref _identifyCode, value); }
  396. }
  397. private void SetCollapsed()
  398. {
  399. this.CurrentSigningBank.PaymentNumberVisibility = false;
  400. this.CurrentSigningBank.ProtocolNumberVisibility = false;
  401. //this.CurrentSigningBank.CertIDVisibility = false;
  402. //this.CurrentSigningBank.BankVisibility = false;
  403. //this.CurrentSigningBank.BranchVisibility = false;
  404. //this.CurrentSigningBank.BankBankAccountNoVisibility = false;
  405. //this.CurrentSigningBank.AccountNameVisibility = false;
  406. this.CurrentSigningBank.AgentNameVisibility = false;
  407. this.CurrentSigningBank.AgentCIDNumberVisibility = false;
  408. this.CurrentSigningBank.BankPasswordVisibility = false;
  409. this.CurrentSigningBank.DrawIdentifyCodeVisibility = false;
  410. if (!string.IsNullOrEmpty(CurrentSigningBank.CancleSignShowField))
  411. {
  412. bool isMemberTrade = UserManager.CurrentTradeAccount.AccountType !=
  413. eUserType.USERTYPE_INVESTOR;
  414. //根据当前所选签约银行,配置输入字段
  415. string[] CancleSignShowField = this.CurrentSigningBank.CancleSignShowField.Split(',');
  416. foreach (string item in CancleSignShowField)
  417. {
  418. switch (int.Parse(item))
  419. {
  420. case (int)ShowFieldStatus.ShowField_PaymentNo:
  421. this.CurrentSigningBank.PaymentNumberVisibility = true;
  422. break;
  423. case (int)ShowFieldStatus.ShowField_ProtocolNo:
  424. this.CurrentSigningBank.ProtocolNumberVisibility = true;
  425. break;
  426. case (int)ShowFieldStatus.ShowField_AgentCertID:
  427. this.CurrentSigningBank.AgentCIDNumberVisibility = isMemberTrade;
  428. break;
  429. case (int)ShowFieldStatus.ShowField_AgentName:
  430. this.CurrentSigningBank.AgentNameVisibility = isMemberTrade;
  431. break;
  432. case (int)ShowFieldStatus.ShowField_BankAccountPWD:
  433. this.CurrentSigningBank.BankPasswordVisibility = true;
  434. //todo获取银行密钥
  435. if (_encryptKey == null)
  436. {
  437. Task.Factory.TryStartNew(() =>
  438. {
  439. IsBusy = true;
  440. var reqkey = new EncryptKeyRequest()
  441. {
  442. Currency = (UserManager.CurrentTradeAccount.FundsAccounts == null || !UserManager.CurrentTradeAccount.FundsAccounts.Any())
  443. ? "RMB" : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency,
  444. CusBankId = CurrentSigningBank.CusBankID+string.Empty
  445. };
  446. // _encryptKey =
  447. _bankService.QueryEncryptKey(reqkey, QueryEncryptKeyCallback_ShowField_BankAccountPWD, ErrorCallback);
  448. }, () => IsBusy = false);
  449. }
  450. break;
  451. case (int)ShowFieldStatus.ShowField_Draw_IdentifyCode:
  452. this.CurrentSigningBank.DrawIdentifyCodeVisibility = true;
  453. //todo获取银行密钥
  454. if (_encryptKey == null)
  455. {
  456. Task.Factory.TryStartNew(() =>
  457. {
  458. IsBusy = true;
  459. var reqkeyIC = new EncryptKeyRequest()
  460. {
  461. Currency = (UserManager.CurrentTradeAccount.FundsAccounts == null || !UserManager.CurrentTradeAccount.FundsAccounts.Any())
  462. ? "RMB" : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency,
  463. CusBankId = CurrentSigningBank.CusBankID+string.Empty
  464. };
  465. //_encryptKey =
  466. _bankService.QueryEncryptKey(reqkeyIC, QueryEncryptKeyCallback_ShowField_Draw_IdentifyCode, ErrorCallback);
  467. }, () => IsBusy = false);
  468. }
  469. break;
  470. }
  471. }
  472. }
  473. var BandIDList = ApplicationParameter.CusBankNetSign.Split(',');
  474. if (CurrentSigningBank.CusBankID == 2 )
  475. {
  476. this.BranchMessage = true;
  477. IsOKEnable = false;
  478. }
  479. else if (BandIDList.Contains(CurrentSigningBank.CusBankID + string.Empty))
  480. {
  481. this.NetMessage = true;
  482. this.NetWorkSignTips = ApplicationParameter.CusBankNetSignTipsInfo;
  483. IsOKEnable = false;
  484. }
  485. else
  486. {
  487. // this.BranchMessage = true;
  488. IsOKEnable = true;
  489. }
  490. }
  491. private void SetSignBankInfo()
  492. {
  493. IsBusy = true;
  494. BusyContent = Muchinfo.MTPClient.Resources.Client_Resource.Bank_GetBankInfomation_waiting;
  495. System.Threading.Tasks.Task.Factory.TryStartNew(
  496. () => System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  497. {
  498. // SigningBank configInfo =
  499. // _bankService.QueryBankParamConfig(CurrentSigningBank.CusBankID, QueryBankparamConfigCallback, ErrorCallback);
  500. })), () => IsBusy = false);
  501. }
  502. private void QueryEncryptKeyCallback_ShowField_Draw_IdentifyCode(EncryptKey encryptKey)
  503. {
  504. if (String.IsNullOrEmpty(_encryptKey.SecretKey))
  505. {
  506. MessageBoxHelper.ShowQuestion(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NoGetIncryption, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Error);
  507. }
  508. }
  509. private void QueryEncryptKeyCallback_ShowField_BankAccountPWD(EncryptKey encryptKey)
  510. {
  511. if (String.IsNullOrEmpty(_encryptKey.SecretKey))
  512. {
  513. MessageBoxHelper.ShowQuestion(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NoGetIncryption, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Error);
  514. }
  515. }
  516. /// <summary>
  517. /// 临时结果
  518. /// </summary>
  519. private BankSignResult temp_ankDealStatus;
  520. public void BankCaneclSignCallback(BankSignResult bankDealStatus)
  521. {
  522. IsBusy = false;
  523. //一般情况银行电话密码和银行取款密码只需要一个
  524. bool isSendBankKey = (CurrentSigningBank.BankPasswordVisibility || CurrentSigningBank.DrawIdentifyCodeVisibility);
  525. temp_ankDealStatus = bankDealStatus;
  526. if (isSendBankKey && bankDealStatus.ReturnCode == 0)
  527. {
  528. var encryptHelper = new TasEncryptHelper();
  529. if (_encryptKey == null)
  530. {
  531. var reqkey = new EncryptKeyRequest()
  532. {
  533. Currency =
  534. (UserManager.CurrentTradeAccount.FundsAccounts == null ||
  535. !UserManager.CurrentTradeAccount.FundsAccounts.Any())
  536. ? "RMB"
  537. : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency,
  538. CusBankId = CurrentSigningBank.CusBankID+string.Empty
  539. };
  540. // _encryptKey =
  541. _bankService.QueryEncryptKey(reqkey, QueryEncryptKeyCallback, ErrorCallback);
  542. }
  543. else
  544. {
  545. string encryptPwd = "";
  546. if (CurrentSigningBank.BankPasswordVisibility)
  547. {
  548. encryptPwd = encryptHelper.EncryptPassd(_encryptKey.SecretKey,
  549. CurrentSigningBank.BankPassword);
  550. }
  551. else if (CurrentSigningBank.DrawIdentifyCodeVisibility)
  552. {
  553. encryptPwd = encryptHelper.EncryptPassd(_encryptKey.SecretKey,
  554. CurrentSigningBank.DrawIdentifyCode);
  555. }
  556. var req = new SignBankPDW()
  557. {
  558. AccountCode = UserManager.CurrentTradeAccount.AccountCode,
  559. ExchTicket = bankDealStatus.ExchTicket,
  560. ExtOperatorID = bankDealStatus.ExtOperatorID,
  561. CusBankId = CurrentSigningBank.CusBankID + string.Empty,
  562. BankAccountPWD = encryptPwd,
  563. Currency =
  564. (UserManager.CurrentTradeAccount.FundsAccounts == null ||
  565. !UserManager.CurrentTradeAccount.FundsAccounts.Any())
  566. ? "RMB"
  567. : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency
  568. };
  569. //errorCode =_bankService.SignBankPwd(req, UserManager.CurrentTradeAccount.LoginCode);
  570. _bankService.SignBankPwd(req, SignBankPwdCallback, ErrorCallback);
  571. }
  572. }
  573. SignBankPwdCallback(bankDealStatus.ReturnCode);
  574. }
  575. private void SignBankPwdCallback(int result)
  576. {
  577. var bankDealStatus = temp_ankDealStatus;
  578. bool isSendBankKey = (CurrentSigningBank.BankPasswordVisibility || CurrentSigningBank.DrawIdentifyCodeVisibility);
  579. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  580. {
  581. if (result == 0)
  582. {
  583. if (isSendBankKey)
  584. {
  585. MessageBoxHelper.ShowSuccess(
  586. Muchinfo.MTPClient.Resources.Client_Resource.Bank_TerminationSuccess,
  587. Muchinfo.MTPClient.Resources.Client_Resource.Bank_BankTerminationTips);
  588. if (bankDealStatus.Status == BankDealStatus.BankDealStatus__BankWebComfirm)
  589. {
  590. IPHelper.OpenWebAddress(bankDealStatus.WebAddress);
  591. var messageBox = new MsgAlter(bankDealStatus.WebAddress, Client_Resource.Tips_BankUnSignWebComfrim)
  592. {
  593. Owner = Application.Current.MainWindow,
  594. WindowStartupLocation = WindowStartupLocation.CenterOwner
  595. };
  596. messageBox.ShowDialog();
  597. }
  598. }
  599. else
  600. {
  601. // LogManager.WriteBankApplyLog(1, CurrentSigningBank, UserManager.CurrentTradeAccount);
  602. switch (bankDealStatus.Status)
  603. {
  604. case BankDealStatus.BankDealStatus__Succeed:
  605. MessageBoxHelper.ShowSuccess(
  606. Muchinfo.MTPClient.Resources.Client_Resource
  607. .Bank_TerminationSuccess,
  608. Muchinfo.MTPClient.Resources.Client_Resource
  609. .Bank_BankTerminationTips);
  610. break;
  611. case BankDealStatus.BankDealStatus__Pend:
  612. MessageBoxHelper.ShowSuccess(
  613. Muchinfo.MTPClient.Resources.Client_Resource
  614. .Bank_BankTerminationInfoSubmit_Wait,
  615. Muchinfo.MTPClient.Resources.Client_Resource
  616. .Bank_BankTerminationTips);
  617. break;
  618. case BankDealStatus.BankDealStatus__BankWebComfirm:
  619. try
  620. {
  621. IPHelper.OpenWebAddress(bankDealStatus.WebAddress);
  622. }
  623. catch (Exception)
  624. {
  625. throw new MuchinfoException(ExceptionManager.OpenIEError);
  626. }
  627. finally
  628. {
  629. var messageBox = new MsgAlter(bankDealStatus.WebAddress, Client_Resource.Tips_BankUnSignWebComfrim)
  630. {
  631. Owner = Application.Current.MainWindow,
  632. WindowStartupLocation = WindowStartupLocation.CenterOwner
  633. };
  634. messageBox.ShowDialog();
  635. }
  636. break;
  637. }
  638. }
  639. // win_BankTerminationView.DialogResult = true;
  640. _view.DialogResult = true;
  641. }
  642. else
  643. {
  644. ErrorManager.ShowReturnError(bankDealStatus.ReturnCode, Muchinfo.MTPClient.Resources.Client_Resource.Bank_ErrotTips);
  645. }
  646. //win_BankTerminationView.bnt_OK.IsEnabled = true;
  647. _view.bnt_OK.IsEnabled = true;
  648. }));
  649. }
  650. private void QueryEncryptKeyCallback(EncryptKey encryptKey)
  651. {
  652. var encryptHelper = new TasEncryptHelper();
  653. var bankDealStatus = temp_ankDealStatus;
  654. string encryptPwd = "";
  655. if (CurrentSigningBank.BankPasswordVisibility)
  656. {
  657. encryptPwd = encryptHelper.EncryptPassd(_encryptKey.SecretKey,
  658. CurrentSigningBank.BankPassword);
  659. }
  660. else if (CurrentSigningBank.DrawIdentifyCodeVisibility)
  661. {
  662. encryptPwd = encryptHelper.EncryptPassd(_encryptKey.SecretKey,
  663. CurrentSigningBank.DrawIdentifyCode);
  664. }
  665. var req = new SignBankPDW()
  666. {
  667. AccountCode = UserManager.CurrentTradeAccount.AccountCode,
  668. ExchTicket = bankDealStatus.ExchTicket,
  669. ExtOperatorID = bankDealStatus.ExtOperatorID,
  670. CusBankId = CurrentSigningBank.CusBankID + string.Empty,
  671. BankAccountPWD = encryptPwd,
  672. Currency =
  673. (UserManager.CurrentTradeAccount.FundsAccounts == null ||
  674. !UserManager.CurrentTradeAccount.FundsAccounts.Any())
  675. ? "RMB"
  676. : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency
  677. };
  678. //errorCode =_bankService.SignBankPwd(req, UserManager.CurrentTradeAccount.LoginCode);
  679. _bankService.SignBankPwd(req, SignBankPwdCallback, ErrorCallback);
  680. SignBankPwdCallback(bankDealStatus.ReturnCode);
  681. }
  682. public void ErrorCallback(ErrorEntity error)
  683. {
  684. IsBusy = false;
  685. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  686. {
  687. ErrorManager.ShowReturnError(error, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Error, true);
  688. }));
  689. }
  690. }
  691. }