BankUpdateViewModel.cs 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003
  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.PC.Common.Extensions;
  17. using Muchinfo.PC.Common.Helpers;
  18. using Muchinfo.WPF.Controls.Windows;
  19. using System;
  20. using System.Collections.Generic;
  21. using System.Collections.ObjectModel;
  22. using System.Linq;
  23. using System.Threading.Tasks;
  24. namespace Muchinfo.MTPClient.Bank.ViewModels
  25. {
  26. public class BankUpdateViewModel : IdentifyCodeTimerViewModel
  27. {
  28. #region 变量成员
  29. private IBankService _bankService;
  30. private BankUpdateView _view;
  31. private EncryptKey _encryptKey;
  32. private AreaAccount _areaAccount; //会员账号信息
  33. private bool _isBusy;
  34. /// <summary>
  35. /// 是否忙,显示等待控件
  36. /// </summary>
  37. public bool IsBusy
  38. {
  39. get { return _isBusy; }
  40. set { Set(() => IsBusy, ref _isBusy, value); }
  41. }
  42. private string _busyContent;
  43. public string BusyContent
  44. {
  45. get { return _busyContent; }
  46. set { Set(() => BusyContent, ref _busyContent, value); }
  47. }
  48. ///<summary>
  49. ///证件类型
  50. ///</summary>
  51. public Dictionary<eCardType, string> ClientCardTypes
  52. {
  53. get
  54. {
  55. //var types = new Dictionary<ClientCardType, string> { { ClientCardType.Id, ClientCardType.Id.Discription() }, { ClientCardType.Driver, ClientCardType.Driver.Discription() } };
  56. //return types;
  57. return EnumExtensions.ToDictionary<eCardType>();
  58. }
  59. }
  60. #region 确认银行账号
  61. private string _BankAccountConfirm = string.Empty;
  62. /// <summary>
  63. /// 确认银行账号
  64. /// </summary>
  65. public string BankAccountConfirm
  66. {
  67. get
  68. {
  69. return _BankAccountConfirm;
  70. }
  71. set
  72. {
  73. Set(() => BankAccountConfirm, ref _BankAccountConfirm, value);
  74. }
  75. }
  76. #endregion
  77. /// <summary>
  78. /// 银行列表数据源
  79. /// </summary>
  80. private List<Banks> BankListSource=new List<Banks>();
  81. private ObservableCollection<Banks> _bankList;
  82. /// <summary>
  83. /// 开户银行列表
  84. /// </summary>
  85. /// <value>The bank branch dictionary.</value>
  86. public ObservableCollection<Banks> BankList
  87. {
  88. get
  89. {
  90. return _bankList;
  91. }
  92. set
  93. {
  94. Set(() => BankList, ref _bankList, value);
  95. }
  96. }
  97. private Banks _selectBankItem;
  98. /// <summary>
  99. /// 选择银行
  100. /// </summary>
  101. public Banks SelectBankItem
  102. {
  103. get
  104. {
  105. return _selectBankItem;
  106. }
  107. set
  108. {
  109. Set(() => SelectBankItem, ref _selectBankItem, value);
  110. if (value != null)
  111. {
  112. CurrentSigningBank.BankId = value.BankId;
  113. CurrentSigningBank.Name = value.BankName;
  114. }
  115. }
  116. }
  117. //private List<SigningBank> _cusBankList = new List<SigningBank>();
  118. ///// <summary>
  119. ///// 签约的托管银行
  120. ///// </summary>
  121. //public List<SigningBank> CusBankList
  122. //{
  123. // get { return _cusBankList; }
  124. // set { Set(() => CusBankList, ref _cusBankList, value); }
  125. //}
  126. //private SigningBank _currentCusBank;
  127. ///// <summary>
  128. ///// 当前选中的托管银行
  129. ///// </summary>
  130. //public SigningBank CurrentCusBank
  131. //{
  132. // get { return _currentCusBank; }
  133. // set
  134. // {
  135. // Set(() => CurrentCusBank, ref _currentCusBank, value);
  136. // if (value != null)
  137. // {
  138. // CurrentSigningBank = SignBankList.FirstOrDefault(m => m.CusBankID == value.CusBankID);
  139. // }
  140. // }
  141. //}
  142. private ObservableCollection<SigningBank> _signBankList;
  143. /// <summary>
  144. /// 客户签约银行列表
  145. /// </summary>
  146. public ObservableCollection<SigningBank> SignBankList
  147. {
  148. get { return _signBankList; }
  149. set { Set(() => SignBankList, ref _signBankList, value); }
  150. }
  151. private List<CusBankInfo> _cusBankInfo;
  152. /// <summary>
  153. /// 托管银行信息
  154. /// </summary>
  155. public List<CusBankInfo> CusBankInfo
  156. {
  157. get { return _cusBankInfo; }
  158. set { _cusBankInfo = value; }
  159. }
  160. #region 变更后银行信息
  161. private SigningBank _newSigningBank = new SigningBank();
  162. /// <summary>
  163. /// Sets and gets the NewSigningBank property.
  164. /// </summary>
  165. public SigningBank NewSigningBank
  166. {
  167. get
  168. {
  169. return _newSigningBank;
  170. }
  171. set
  172. {
  173. Set(() => NewSigningBank, ref _newSigningBank, value);
  174. }
  175. }
  176. #endregion
  177. private SigningBank _currentSigningBank;
  178. /// <summary>
  179. /// 当前选中签约银行
  180. /// </summary>
  181. public SigningBank CurrentSigningBank
  182. {
  183. get
  184. {
  185. return _currentSigningBank;
  186. }
  187. set
  188. {
  189. Set(() => CurrentSigningBank, ref _currentSigningBank, value);
  190. //银行Id获取银行支行列表
  191. //Dictionary<string, string> BankBranchDictionary = _bankService.GetBankBranchList(value.Id);
  192. //支行Id获取支行名称
  193. //BranchName = BankBranchDictionary[value.BranchId];
  194. CredentialTypeName = ClientCardTypes[value.CredentialType];
  195. SetCollapsed();
  196. SetSignBankInfo();
  197. }
  198. }
  199. private string _credentialTypeName;
  200. /// <summary>
  201. /// 开户人证件类型名称
  202. /// </summary>
  203. public string CredentialTypeName
  204. {
  205. get
  206. {
  207. return _credentialTypeName;
  208. }
  209. set
  210. {
  211. Set(() => CredentialTypeName, ref _credentialTypeName, value);
  212. }
  213. }
  214. private string _branchName;
  215. /// <summary>
  216. /// 开户银行支行名称
  217. /// </summary>
  218. public string BranchName
  219. {
  220. get
  221. {
  222. return _branchName;
  223. }
  224. set
  225. {
  226. Set(() => BranchName, ref _branchName, value);
  227. }
  228. }
  229. /// <summary>
  230. /// 建行三方提示
  231. /// </summary>
  232. private bool _branchMessage = false;
  233. /// <summary>
  234. /// 建行三方提示
  235. /// </summary>
  236. public bool BranchMessage
  237. {
  238. get
  239. {
  240. return _branchMessage;
  241. }
  242. set
  243. {
  244. Set(() => BranchMessage, ref _branchMessage, value);
  245. }
  246. }
  247. /// <summary>
  248. /// 网银签约解约提示
  249. /// </summary>
  250. private bool _netMessage = false;
  251. /// <summary>
  252. /// 网银签约解约提示
  253. /// </summary>
  254. public bool NetMessage
  255. {
  256. get
  257. {
  258. return _netMessage;
  259. }
  260. set
  261. {
  262. Set(() => NetMessage, ref _netMessage, value);
  263. }
  264. }
  265. private string _netWorkSignTips;
  266. /// <summary>
  267. /// 网银端提示
  268. /// </summary>
  269. public string NetWorkSignTips
  270. {
  271. get { return _netWorkSignTips; }
  272. set
  273. {
  274. Set(() => NetWorkSignTips, ref _netWorkSignTips, value);
  275. }
  276. }
  277. /// <summary>
  278. /// 是否可点确定
  279. /// </summary>
  280. private bool _isOKEnable = true;
  281. /// <summary>
  282. /// 是否可点确定
  283. /// </summary>
  284. public bool IsOKEnable
  285. {
  286. get
  287. {
  288. return _isOKEnable;
  289. }
  290. set
  291. {
  292. Set(() => IsOKEnable, ref _isOKEnable, value);
  293. }
  294. }
  295. /// <summary>
  296. ///银行列表
  297. /// </summary>
  298. List<Banks> AccoumtBankSignList;
  299. #endregion
  300. #region 构造函数
  301. public BankUpdateViewModel(BankUpdateView view)
  302. {
  303. _view = view;
  304. IsBusy = true;
  305. temp_ankDealStatus = null;
  306. BusyContent = Muchinfo.MTPClient.Resources.Client_Resource.Bank_GetBankInfo_Waiting;
  307. _bankService = SimpleIoc.Default.GetInstance<IBankService>();
  308. // _bankService.QueryBankInfo(QueryBankInfoCallback, ErrorCallback);
  309. //todo: QueryBankCustomerSign 未返回CusBankName 先查询QueryCusBankInfo返回匹配该字段
  310. // SignBankList =
  311. //_bankService.QueryBankCustomerSign(QueryBankCustomerSignCallback, ErrorCallback);
  312. var accountid = UserManager.CurrentTradeAccount.AccountId;
  313. //if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
  314. //{
  315. // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
  316. //}
  317. _bankService.QueryBankCustomerSignInfo(accountid, SearchBankCustomerSignCallback, ErrorCallback);
  318. }
  319. /// <summary>
  320. /// 查询签约信息回应
  321. /// </summary>
  322. /// <param name="list"></param>
  323. private void SearchBankCustomerSignCallback(List<SigningBank> list)
  324. {
  325. IsBusy = false;
  326. if (ApplicationParameter.NewBankPlatform == 1) ////新银行平台
  327. {
  328. SignBankList = new ObservableCollection<SigningBank>(list);
  329. }
  330. else
  331. {
  332. SignBankList = new ObservableCollection<SigningBank>(list.Where((item) => item.ShowCancelSign == 0 && item.SignStatusType == SignStatus.SignStatus_Signed));
  333. }
  334. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  335. {
  336. if (SignBankList == null || SignBankList.Count <= 0)
  337. {
  338. MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NoSignWithBank, Muchinfo.MTPClient.Resources.Client_Resource.APP_Tips);
  339. // BankUpdateView.Close();
  340. _view.Close();
  341. return;
  342. }
  343. CurrentSigningBank = SignBankList.FirstOrDefault();
  344. BankAccountConfirm = CurrentSigningBank.BankAccount;
  345. }));
  346. }
  347. private void QueryBankCustomerSignCallback(ObservableCollection<SigningBank> list)
  348. {
  349. IsBusy = false;
  350. SignBankList = new ObservableCollection<SigningBank>(list.Where((item) => item.ShowCancelSign == 0 && item.SignStatusType==SignStatus.SignStatus_Signed));
  351. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  352. {
  353. if (SignBankList == null || SignBankList.Count <= 0)
  354. {
  355. MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NoSignWithBank, Muchinfo.MTPClient.Resources.Client_Resource.APP_Tips);
  356. // BankUpdateView.Close();
  357. _view.Close();
  358. return;
  359. }
  360. if (null != AccoumtBankSignList && AccoumtBankSignList.Any())
  361. {
  362. foreach (var item in SignBankList)
  363. {
  364. foreach (var k in AccoumtBankSignList)
  365. {
  366. if (item.BankId == k.BankId)
  367. {
  368. item.Name = k.BankName;
  369. // item.AccountName = UserManager.CurrentTradeAccount.CustomerName;
  370. }
  371. if (item.BranchId == k.BankId)
  372. {
  373. item.BranchBankName = k.BankName;
  374. }
  375. }
  376. }
  377. }
  378. CurrentSigningBank = SignBankList.FirstOrDefault();
  379. }));
  380. }
  381. #endregion
  382. public RelayCommand<BankUpdateView> OkCommand
  383. {
  384. get
  385. {
  386. return new RelayCommand<BankUpdateView>((win_BankUpdateView) =>
  387. {
  388. if (CurrentSigningBank == null)
  389. {
  390. return;
  391. }
  392. if (Validate())
  393. {
  394. IsBusy = true;
  395. BusyContent = Muchinfo.MTPClient.Resources.Client_Resource.Bank_SubmitChangeBankInfo_Wait;
  396. this.NewSigningBank.CusBankID = CurrentSigningBank.CusBankID;
  397. this.NewSigningBank.CustomerSignId = CurrentSigningBank.CustomerSignId;
  398. this.NewSigningBank.AccountName = CurrentSigningBank.AccountName;
  399. this.NewSigningBank.BankAccount = CurrentSigningBank.BankAccount;
  400. this.NewSigningBank.BankId = CurrentSigningBank.BankId;
  401. this.NewSigningBank.Name = CurrentSigningBank.Name;
  402. if (CurrentSigningBank.MobilePhone!="")
  403. this.NewSigningBank.MobilePhone = CurrentSigningBank.MobilePhone;
  404. NewSigningBank.ExtOperatorID = UserManager.CurrentTradeAccount.AccountId;
  405. NewSigningBank.AccountType = UserManager.CurrentTradeAccount.AccountType;
  406. NewSigningBank.AccountCode = UserManager.CurrentTradeAccount.AccountCode;
  407. _bankService.SignUpdate(NewSigningBank, SignUpdateCallback, ErrorCallback);
  408. }
  409. });
  410. }
  411. }
  412. /// <summary>
  413. /// 验证
  414. /// </summary>
  415. /// <returns>是否通过</returns>
  416. private bool Validate()
  417. {
  418. if (string.IsNullOrEmpty(CurrentSigningBank.BankAccount))
  419. {
  420. MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_InputBankAccount, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
  421. return false;
  422. }
  423. if (string.IsNullOrEmpty(this.BankAccountConfirm))
  424. {
  425. MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_ConfirmBankAccount, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
  426. return false;
  427. }
  428. if (this.CurrentSigningBank.BankAccount.Trim() != BankAccountConfirm)
  429. {
  430. MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_InputBankAccountDifferent, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
  431. return false;
  432. }
  433. //if (this.NewBankAccount.Trim() == this.BankAccount.Trim())
  434. //{
  435. // MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NewAndOldAccountSame, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
  436. // return false;
  437. //}
  438. return true;
  439. }
  440. /// <summary>
  441. /// 取消
  442. /// </summary>
  443. public RelayCommand<BankUpdateView> CancelCommand
  444. {
  445. get
  446. {
  447. temp_ankDealStatus = null;
  448. return new RelayCommand<BankUpdateView>((win_BankUpdateView) =>
  449. {
  450. win_BankUpdateView.Close();
  451. });
  452. }
  453. }
  454. private void SignUpdateCallback(int result)
  455. {
  456. IsBusy = false;
  457. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  458. {
  459. if (result == 0)
  460. {
  461. MessageBoxHelper.ShowSuccess(Muchinfo.MTPClient.Resources.Client_Resource.Bank_ChangeBankInfoSuccess_Wait, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
  462. _view.Close();
  463. }
  464. else
  465. {
  466. ErrorManager.ShowReturnError(result, Muchinfo.MTPClient.Resources.Client_Resource.Bank_ErrotTips);
  467. }
  468. }));
  469. }
  470. private void SetCollapsed()
  471. {
  472. this.CurrentSigningBank.PaymentNumberVisibility = false;
  473. this.CurrentSigningBank.ProtocolNumberVisibility = false;
  474. this.CurrentSigningBank.MobilePhoneVisibility = false;
  475. //this.CurrentSigningBank.CertIDVisibility = false;
  476. //this.CurrentSigningBank.BankVisibility = false;
  477. //this.CurrentSigningBank.BranchVisibility = false;
  478. //this.CurrentSigningBank.BankBankAccountNoVisibility = false;
  479. //this.CurrentSigningBank.AccountNameVisibility = false;
  480. this.CurrentSigningBank.AgentNameVisibility = false;
  481. this.CurrentSigningBank.AgentCIDNumberVisibility = false;
  482. this.CurrentSigningBank.BankPasswordVisibility = false;
  483. this.CurrentSigningBank.DrawIdentifyCodeVisibility = false;
  484. if (!string.IsNullOrEmpty(CurrentSigningBank.ShowField))
  485. {
  486. bool isMemberTrade = UserManager.CurrentTradeAccount.AccountType !=
  487. eUserType.USERTYPE_INVESTOR;
  488. //根据当前所选签约银行,配置输入字段
  489. string[] SignShowField = this.CurrentSigningBank.ShowField.Split(',');
  490. foreach (string item in SignShowField)
  491. {
  492. switch (int.Parse(item))
  493. {
  494. case (int)ShowFieldStatus.ShowField_PaymentNo:
  495. this.CurrentSigningBank.PaymentNumberVisibility = true;
  496. break;
  497. case (int)ShowFieldStatus.ShowField_ProtocolNo:
  498. this.CurrentSigningBank.ProtocolNumberVisibility = true;
  499. break;
  500. //case (int)ShowFieldStatus.ShowField_CertID:
  501. // this.CurrentSigningBank.CertIDVisibility = Visibility.Visible;
  502. // break;
  503. //case (int)ShowFieldStatus.ShowField_Bank:
  504. // this.CurrentSigningBank.BankVisibility = Visibility.Visible;
  505. // break;
  506. //case (int)ShowFieldStatus.ShowField_BranchBank:
  507. // this.CurrentSigningBank.BranchVisibility = Visibility.Visible;
  508. // break;
  509. //case (int)ShowFieldStatus.ShowField_BankAccountNo:
  510. // this.CurrentSigningBank.BankBankAccountNoVisibility = Visibility.Visible;
  511. // break;
  512. //case (int)ShowFieldStatus.ShowField_AccountName:
  513. // this.CurrentSigningBank.AccountNameVisibility = Visibility.Visible;
  514. // break;
  515. case (int)ShowFieldStatus.ShowField_AgentCertID:
  516. this.CurrentSigningBank.AgentCIDNumberVisibility = isMemberTrade;
  517. break;
  518. case (int)ShowFieldStatus.ShowField_AgentName:
  519. this.CurrentSigningBank.AgentNameVisibility = isMemberTrade;
  520. break;
  521. case (int)ShowFieldStatus.ShowField_BankAccountPWD:
  522. this.CurrentSigningBank.BankPasswordVisibility = true;
  523. //todo获取银行密钥
  524. if (_encryptKey == null)
  525. {
  526. Task.Factory.TryStartNew(() =>
  527. {
  528. IsBusy = true;
  529. var reqkey = new EncryptKeyRequest()
  530. {
  531. Currency = (UserManager.CurrentTradeAccount.FundsAccounts == null || !UserManager.CurrentTradeAccount.FundsAccounts.Any())
  532. ? "RMB" : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency,
  533. CusBankId = CurrentSigningBank.CusBankID+string.Empty
  534. };
  535. // _encryptKey =
  536. _bankService.QueryEncryptKey(reqkey, QueryEncryptKeyCallback_ShowField_BankAccountPWD, ErrorCallback);
  537. }, () => IsBusy = false);
  538. }
  539. break;
  540. case (int)ShowFieldStatus.ShowField_Draw_IdentifyCode:
  541. this.CurrentSigningBank.DrawIdentifyCodeVisibility = true;
  542. //todo获取银行密钥
  543. if (_encryptKey == null)
  544. {
  545. Task.Factory.TryStartNew(() =>
  546. {
  547. IsBusy = true;
  548. var reqkeyIC = new EncryptKeyRequest()
  549. {
  550. Currency = (UserManager.CurrentTradeAccount.FundsAccounts == null || !UserManager.CurrentTradeAccount.FundsAccounts.Any())
  551. ? "RMB" : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency,
  552. CusBankId = CurrentSigningBank.CusBankID+string.Empty
  553. };
  554. //_encryptKey =
  555. _bankService.QueryEncryptKey(reqkeyIC, QueryEncryptKeyCallback_ShowField_Draw_IdentifyCode, ErrorCallback);
  556. }, () => IsBusy = false);
  557. }
  558. break;
  559. //case (int)ShowFieldStatus.ShowField_MobilePhone:
  560. // this.CurrentSigningBank.MobilePhoneVisibility = true;
  561. // break;
  562. }
  563. }
  564. }
  565. var BandIDList = ApplicationParameter.CusBankNetSign.Split(',');
  566. if (CurrentSigningBank.CusBankID == 2 )
  567. {
  568. this.BranchMessage = true;
  569. IsOKEnable = false;
  570. }
  571. else if (BandIDList.Contains(CurrentSigningBank.CusBankID + string.Empty))
  572. {
  573. this.NetMessage = true;
  574. this.NetWorkSignTips = ApplicationParameter.CusBankNetSignTipsInfo;
  575. IsOKEnable = false;
  576. }
  577. else
  578. {
  579. // this.BranchMessage = true;
  580. IsOKEnable = true;
  581. }
  582. }
  583. private void SetSignBankInfo()
  584. {
  585. IsBusy = true;
  586. BusyContent = Muchinfo.MTPClient.Resources.Client_Resource.Bank_GetBankInfomation_waiting;
  587. System.Threading.Tasks.Task.Factory.TryStartNew(
  588. () => System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  589. {
  590. var accountid = UserManager.CurrentTradeAccount.AccountId;
  591. //if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
  592. //{
  593. // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
  594. //}
  595. _bankService.QueryCusBankParamConfig(accountid, QueryBankparamConfigCallback, ErrorCallback);
  596. })), () => IsBusy = false);
  597. }
  598. private void QueryBankparamConfigCallback(List<CusBankInfo> bankconfigs)
  599. {
  600. IsBusy = false;
  601. var bankConfig = bankconfigs.FirstOrDefault((item) => item.CusBankId == CurrentSigningBank.CusBankID);
  602. _cusBankInfo = bankconfigs;
  603. if (bankConfig != null && !string.IsNullOrEmpty(bankConfig.BankListId))
  604. {
  605. //根据配置字段过滤总行
  606. if (this.BankListSource == null || this.BankListSource.Count<=0)
  607. {
  608. var queryCommons = new List<QueryCommonParam>();
  609. _bankService.QueryCommonBankInfo(queryCommons, QueryBankInfoCallback, ErrorCallback);
  610. }
  611. else
  612. {
  613. SetbankListInfo(bankConfig);
  614. }
  615. }
  616. else
  617. {
  618. MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_ChooseSignBankParameterSetError, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
  619. this.BankList = null;
  620. _view.bnt_OK.IsEnabled = false;
  621. }
  622. if (CurrentSigningBank.CusBankID == 2)
  623. {
  624. //this.BranchMessage = Visibility.Visible;
  625. _view.bnt_OK.IsEnabled = false;
  626. }
  627. }
  628. private void SetbankListInfo(CusBankInfo signingBank)
  629. {
  630. string[] bankListId = signingBank.BankListId.Split(',');
  631. List<Banks> bankList = new List<Banks>();
  632. foreach (string item in bankListId)
  633. {
  634. var bankId = item.Trim((@"\r\n").ToCharArray());
  635. Banks bank = this.BankListSource.FirstOrDefault(c => c.BankId == bankId);
  636. if (bank != null)
  637. {
  638. bankList.Add(bank);
  639. }
  640. }
  641. this.BankList = new ObservableCollection<Banks>(bankList);
  642. this.SelectBankItem = bankList.FirstOrDefault();
  643. _view.bnt_OK.IsEnabled = true;
  644. }
  645. private void QueryBankList()
  646. {
  647. var bankConfig = _cusBankInfo.FirstOrDefault((item) => item.CusBankId == CurrentSigningBank.CusBankID);
  648. //根据配置字段过滤总行
  649. if (bankConfig != null && !string.IsNullOrEmpty(bankConfig.BankListId))
  650. {
  651. var queryCommons = new List<QueryCommonParam>();
  652. if (this.BankListSource == null || BankListSource.Count() == 0)
  653. {
  654. _bankService.QueryCommonBankInfo(queryCommons,QueryBankInfoCallback, ErrorCallback);
  655. }
  656. else
  657. {
  658. string[] bankListId = bankConfig.BankListId.Split(',');
  659. List<Banks> bankList = new List<Banks>();
  660. foreach (string item in bankListId)
  661. {
  662. var bankId = item.Trim((@"\r\n").ToCharArray());
  663. Banks bank = this.BankListSource.FirstOrDefault(c => c.BankId == bankId);
  664. if (bank != null)
  665. {
  666. bankList.Add(bank);
  667. }
  668. }
  669. this.SelectBankItem = bankList.FirstOrDefault(x => x.BankId == CurrentSigningBank.BankId);
  670. this.BankList = new ObservableCollection<Banks>(bankList);
  671. _view.bnt_OK.IsEnabled = true;
  672. }
  673. }
  674. else
  675. {
  676. MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_SignBank_ParameterError, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
  677. this.BankList = null;
  678. _view.bnt_OK.IsEnabled = false;
  679. }
  680. }
  681. public void QueryBankInfoCallback(List<Banks> list)
  682. {
  683. IsBusy = false;
  684. this.BankListSource = list;
  685. //this.BankList = new ObservableCollection<Banks>(list);
  686. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  687. {
  688. QueryBankList();
  689. //string[] bankListId = this.CurrentSigningBank.BankListId.Split(',');
  690. //List<Banks> bankList = new List<Banks>();
  691. //foreach (string item in bankListId)
  692. //{
  693. // var bankId = item.Trim((@"\r\n").ToCharArray());
  694. // Banks bank = this.BankListSource.FirstOrDefault(c => c.BankId == bankId);
  695. // if (bank != null)
  696. // {
  697. // bankList.Add(bank);
  698. // }
  699. //}
  700. //this.SelectBankItem = bankList.FirstOrDefault();
  701. //this.BankList = new ObservableCollection<Banks>(bankList);
  702. //_view.bnt_OK.IsEnabled = true;
  703. }));
  704. }
  705. private void QueryEncryptKeyCallback_ShowField_Draw_IdentifyCode(EncryptKey encryptKey)
  706. {
  707. if (String.IsNullOrEmpty(_encryptKey.SecretKey))
  708. {
  709. MessageBoxHelper.ShowQuestion(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NoGetIncryption, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Error);
  710. }
  711. }
  712. private void QueryEncryptKeyCallback_ShowField_BankAccountPWD(EncryptKey encryptKey)
  713. {
  714. if (String.IsNullOrEmpty(_encryptKey.SecretKey))
  715. {
  716. MessageBoxHelper.ShowQuestion(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NoGetIncryption, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Error);
  717. }
  718. }
  719. /// <summary>
  720. /// 临时结果
  721. /// </summary>
  722. private BankSignResult temp_ankDealStatus;
  723. public void BankCaneclSignCallback(BankSignResult bankDealStatus)
  724. {
  725. IsBusy = false;
  726. //一般情况银行电话密码和银行取款密码只需要一个
  727. bool isSendBankKey = (CurrentSigningBank.BankPasswordVisibility || CurrentSigningBank.DrawIdentifyCodeVisibility);
  728. temp_ankDealStatus = bankDealStatus;
  729. if (isSendBankKey && bankDealStatus.ReturnCode == 0)
  730. {
  731. var encryptHelper = new TasEncryptHelper();
  732. if (_encryptKey == null)
  733. {
  734. var reqkey = new EncryptKeyRequest()
  735. {
  736. Currency =
  737. (UserManager.CurrentTradeAccount.FundsAccounts == null ||
  738. !UserManager.CurrentTradeAccount.FundsAccounts.Any())
  739. ? "RMB"
  740. : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency,
  741. CusBankId = CurrentSigningBank.CusBankID+string.Empty
  742. };
  743. // _encryptKey =
  744. _bankService.QueryEncryptKey(reqkey, QueryEncryptKeyCallback, ErrorCallback);
  745. }
  746. else
  747. {
  748. string encryptPwd = "";
  749. if (CurrentSigningBank.BankPasswordVisibility)
  750. {
  751. encryptPwd = encryptHelper.EncryptPassd(_encryptKey.SecretKey,
  752. CurrentSigningBank.BankPassword);
  753. }
  754. else if (CurrentSigningBank.DrawIdentifyCodeVisibility)
  755. {
  756. encryptPwd = encryptHelper.EncryptPassd(_encryptKey.SecretKey,
  757. CurrentSigningBank.DrawIdentifyCode);
  758. }
  759. var req = new SignBankPDW()
  760. {
  761. AccountCode = UserManager.CurrentTradeAccount.AccountCode,
  762. ExchTicket = bankDealStatus.ExchTicket,
  763. ExtOperatorID = bankDealStatus.ExtOperatorID,
  764. CusBankId = CurrentSigningBank.CusBankID + string.Empty,
  765. BankAccountPWD = encryptPwd,
  766. Currency =
  767. (UserManager.CurrentTradeAccount.FundsAccounts == null ||
  768. !UserManager.CurrentTradeAccount.FundsAccounts.Any())
  769. ? "RMB"
  770. : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency
  771. };
  772. //errorCode =_bankService.SignBankPwd(req, UserManager.CurrentTradeAccount.LoginCode);
  773. _bankService.SignBankPwd(req, SignBankPwdCallback, ErrorCallback);
  774. }
  775. }
  776. SignBankPwdCallback(bankDealStatus.ReturnCode);
  777. }
  778. private void SignBankPwdCallback(int result)
  779. {
  780. var bankDealStatus = temp_ankDealStatus;
  781. bool isSendBankKey = (CurrentSigningBank.BankPasswordVisibility || CurrentSigningBank.DrawIdentifyCodeVisibility);
  782. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  783. {
  784. if (result == 0)
  785. {
  786. if (isSendBankKey)
  787. {
  788. MessageBoxHelper.ShowSuccess(
  789. Muchinfo.MTPClient.Resources.Client_Resource.Bank_TerminationSuccess,
  790. Muchinfo.MTPClient.Resources.Client_Resource.APP_Tips);
  791. if (bankDealStatus.Status == BankDealStatus.BankDealStatus__BankWebComfirm)
  792. {
  793. IPHelper.OpenWebAddress(bankDealStatus.WebAddress);
  794. var messageBox = new MsgAlter(bankDealStatus.WebAddress)
  795. {
  796. Owner = Application.Current.MainWindow,
  797. WindowStartupLocation = WindowStartupLocation.CenterOwner
  798. };
  799. messageBox.ShowDialog();
  800. }
  801. }
  802. else
  803. {
  804. // LogManager.WriteBankApplyLog(1, CurrentSigningBank, UserManager.CurrentTradeAccount);
  805. switch (bankDealStatus.Status)
  806. {
  807. case BankDealStatus.BankDealStatus__Succeed:
  808. MessageBoxHelper.ShowSuccess(
  809. Muchinfo.MTPClient.Resources.Client_Resource
  810. .Bank_TerminationSuccess,
  811. Muchinfo.MTPClient.Resources.Client_Resource
  812. .APP_Tips);
  813. break;
  814. case BankDealStatus.BankDealStatus__Pend:
  815. MessageBoxHelper.ShowSuccess(
  816. Muchinfo.MTPClient.Resources.Client_Resource
  817. .Bank_BankTerminationInfoSubmit_Wait,
  818. Muchinfo.MTPClient.Resources.Client_Resource
  819. .APP_Tips);
  820. break;
  821. case BankDealStatus.BankDealStatus__BankWebComfirm:
  822. try
  823. {
  824. IPHelper.OpenWebAddress(bankDealStatus.WebAddress);
  825. }
  826. catch (Exception)
  827. {
  828. throw new MuchinfoException(ExceptionManager.OpenIEError);
  829. }
  830. finally
  831. {
  832. var messageBox = new MsgAlter(bankDealStatus.WebAddress)
  833. {
  834. Owner = Application.Current.MainWindow,
  835. WindowStartupLocation = WindowStartupLocation.CenterOwner
  836. };
  837. messageBox.ShowDialog();
  838. }
  839. break;
  840. }
  841. }
  842. // win_BankUpdateView.DialogResult = true;
  843. _view.DialogResult = true;
  844. }
  845. else
  846. {
  847. ErrorManager.ShowReturnError(bankDealStatus.ReturnCode, Muchinfo.MTPClient.Resources.Client_Resource.Bank_ErrotTips);
  848. }
  849. //win_BankUpdateView.bnt_OK.IsEnabled = true;
  850. _view.bnt_OK.IsEnabled = true;
  851. }));
  852. }
  853. private void QueryEncryptKeyCallback(EncryptKey encryptKey)
  854. {
  855. var encryptHelper = new TasEncryptHelper();
  856. var bankDealStatus = temp_ankDealStatus;
  857. string encryptPwd = "";
  858. if (CurrentSigningBank.BankPasswordVisibility)
  859. {
  860. encryptPwd = encryptHelper.EncryptPassd(_encryptKey.SecretKey,
  861. CurrentSigningBank.BankPassword);
  862. }
  863. else if (CurrentSigningBank.DrawIdentifyCodeVisibility)
  864. {
  865. encryptPwd = encryptHelper.EncryptPassd(_encryptKey.SecretKey,
  866. CurrentSigningBank.DrawIdentifyCode);
  867. }
  868. var req = new SignBankPDW()
  869. {
  870. AccountCode = UserManager.CurrentTradeAccount.AccountCode,
  871. ExchTicket = bankDealStatus.ExchTicket,
  872. ExtOperatorID = bankDealStatus.ExtOperatorID,
  873. CusBankId = CurrentSigningBank.CusBankID + string.Empty,
  874. BankAccountPWD = encryptPwd,
  875. Currency =
  876. (UserManager.CurrentTradeAccount.FundsAccounts == null ||
  877. !UserManager.CurrentTradeAccount.FundsAccounts.Any())
  878. ? "RMB"
  879. : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency
  880. };
  881. //errorCode =_bankService.SignBankPwd(req, UserManager.CurrentTradeAccount.LoginCode);
  882. _bankService.SignBankPwd(req, SignBankPwdCallback, ErrorCallback);
  883. SignBankPwdCallback(bankDealStatus.ReturnCode);
  884. }
  885. public void ErrorCallback(ErrorEntity error)
  886. {
  887. IsBusy = false;
  888. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  889. {
  890. ErrorManager.ShowReturnError(error, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Error, true);
  891. }));
  892. }
  893. }
  894. }