| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451 |
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- //----------------------------------------------------------------
- //Module Name: $safeprojectname$
- //Purpose:
- //CopyRight: Muchinfo
- //History:
- //----------------------------------------------------------------
- //DateTime 2017/3/14 16:19:23
- //Author
- //Description Create
- //----------------------------------------------------------------
- using System.Threading.Tasks;
- 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.Model.Account;
- using Muchinfo.MTPClient.Data.Model.Bank;
- using Muchinfo.MTPClient.Data.Model.Config;
- using Muchinfo.MTPClient.Infrastructure.Helpers;
- using Muchinfo.MTPClient.Infrastructure.MessageBox;
- using Muchinfo.MTPClient.Infrastructure.Utilities;
- using Muchinfo.MTPClient.Infrastructure.Windows;
- using Muchinfo.MTPClient.IService;
- using Muchinfo.MTPClient.Resources;
- using Muchinfo.PC.Common.Bosn;
- using Muchinfo.PC.Common.Extensions;
- using Muchinfo.PC.Common.Helpers;
- namespace Muchinfo.MTPClient.Bank.ViewModels
- {
- public class BankSignQueryViewModel : QueryPanelModelBase
- {
- private bool _isBusy;
- /// <summary>
- /// 是否忙,显示等待控件
- /// </summary>
- public bool IsBusy
- {
- get { return _isBusy; }
- set { Set(() => IsBusy, ref _isBusy, value); }
- }
- private IBankService _bankService;
- private List<SigningBank> _signingBanks;
- /// <summary>
- /// 签约银行信息
- /// </summary>
- public List<SigningBank> SigningBanks
- {
- get { return _signingBanks; }
- set { Set(() => SigningBanks, ref _signingBanks, value); }
- }
- private SigningBank _currentSigningBank;
- /// <summary>
- /// 当前选中签约银行
- /// </summary>
- public SigningBank CurrentSigningBank
- {
- get
- {
- return _currentSigningBank;
- }
- set
- {
- Set(() => CurrentSigningBank, ref _currentSigningBank, value);
- }
- }
- public BankSignQueryViewModel()
- {
- _bankService = SimpleIoc.Default.GetInstance<IBankService>();
-
- RefreshContent();
- }
-
- /// <summary>
- /// 查询签约信息回应
- /// </summary>
- /// <param name="list"></param>
- private void SearchBankCustomerSignCallback(List<SigningBank> list)
- {
- //#if DEBUG
- // list.Add(new SigningBank()
- // {
- // AccountCode =UserManager.CurrentTradeAccount.AccountCode,
- // AccountName = UserManager.CurrentTradeAccount.CustomerName,
-
- // ExchId = "111",
- // CusBankID = 38,
- // AccountType = UserManager.CurrentTradeAccount.AccountType,
- // Name = "民生市场通",
- // BankAccount = "44587857854755788985",
- // AppDateTime = ApplicationParameter.ServerTimeNow.ToString("yyyy-MM-dd HH:mm"),
- // BankId = 438+string.Empty,
- // BankCardType = 2,
- // CredentialType = eCardType.IDCARD,
- // CredentialNumber="447858785693561255",
- // SignStatusType = SignStatus.SignStatus_Signed,
-
- // });
- //#endif
-
- var BandIDList = ApplicationParameter.CusBankNetSign.Split(',');
-
- foreach (var signingBank in list)
- {
- if (BandIDList.Contains(signingBank.CusBankID + string.Empty))
- {
- signingBank.IsShowUnSignBtn = false;
-
- }
- signingBank.IsConfingCard = ApplicationParameter.IsConfigShowBingCard == 1;
- }
- IsBusy = false;
- if (ApplicationParameter.NewBankPlatform == 1) ////新银行平台
- {
- SigningBanks = list.Where((item) => item.ShowCancelSign == 0).ToList() ;
- }
- else
- {
- SigningBanks = new List<SigningBank>(list.Where((item) => item.ShowCancelSign == 0 && item.SignStatusType == SignStatus.SignStatus_Signed));
- }
- }
- 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);
- }));
- }
- /// <summary>
- /// 解约操作
- /// </summary>
- public RelayCommand TerminationCommand
- {
- get
- {
- return new RelayCommand(() =>
- {
- if (CurrentSigningBank == null) return;
-
- if (!string.IsNullOrEmpty(CurrentSigningBank.CancleSignShowField))
- {
- //根据当前所选签约银行,配置输入字段
- string[] CancleSignShowField = this.CurrentSigningBank.CancleSignShowField.Split(',');
- if (CancleSignShowField.Contains(((int) ShowFieldStatus.ShowField_Draw_IdentifyCode) +
- string.Empty) ||
- CancleSignShowField.Contains(((int) ShowFieldStatus.ShowField_IdentifyCode) + string.Empty))
- {
- ///需要密码或电话验证码弹出
- var signView = new TerminationSignView(CurrentSigningBank, CancleSignShowField){Owner = Application.Current.MainWindow,WindowStartupLocation = WindowStartupLocation.CenterOwner};
- signView.ShowDialog();
- return;
- }
- }
- var result =
- MessageBoxHelper.ShowQuestion(string.Format(Client_Resource
- .Bank_UnSignTips , CurrentSigningBank.CusBankName),
- Client_Resource.APP_Tips);
- if (MessageBoxResult.Yes == result)
- {
- CurrentSigningBank.CurrentTime = ApplicationParameter.ServerTimeNow;
- CurrentSigningBank.ExtOperatorID = UserManager.CurrentTradeAccount.AccountId;
- //CurrentSigningBank.AccountCode = UserManager.CurrentTradeAccount.AccountCode;
- //CurrentSigningBank.CustomerName = UserManager.CurrentTradeAccount.CustomerName;
- CurrentSigningBank.AccountType = UserManager.CurrentTradeAccount.AccountType;
- IsBusy = true;
- _bankService.BankCaneclSign(CurrentSigningBank, UnSignBankCallback, ErrorCallback);
- }
- });
- }
- }
- private RelayCommand<SigningBank> _UnBingCardCommand;
- /// <summary>
- /// 解绑银行卡
- /// </summary>
- public RelayCommand<SigningBank> UnBingCardCommand
- {
- get
- {
- return _UnBingCardCommand ?? (_UnBingCardCommand = new RelayCommand<SigningBank>((sign) =>
- {
- if (sign != null)
- {
- var result= MessageBoxHelper.ShowQuestion(
- Muchinfo.MTPClient.Resources.Client_Resource
- .Tips_BankUnBindCardComfrim,
- Muchinfo.MTPClient.Resources.Client_Resource
- .APP_Tips);
- if (result == MessageBoxResult.Yes)
- {
- IsBusy = true;
- _bankService.BankUnBindBankCard(sign, BankUnBindCardSuccess, ErrorCallback);
- }
- }
-
- }));
- }
- }
- private void BankUnBindCardSuccess(BankUnBindResult bankResult)
- {
- IsBusy = false;
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- if (bankResult.ReturnCode == 0)
- {
- //switch (bankResult.Status)
- //{
- // case BankDealStatus.BankDealStatus__Succeed:
- if (string.IsNullOrWhiteSpace(bankResult.WebAddress))
- {
- MessageBoxHelper.ShowSuccess(
- Muchinfo.MTPClient.Resources.Client_Resource
- .Tips_BankunBindCardSuccess,
- 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:
- else
- {
- try
- {
- IPHelper.OpenWebAddress(bankResult.WebAddress);
- }
- catch (Exception)
- {
- throw new MuchinfoException(ExceptionManager.OpenIEError);
- }
- finally
- {
- var messageBox = new MsgAlter(bankResult.WebAddress,
- Client_Resource.Tips_BankunBindCardWebComfrim)
- {
- Owner = System.Windows.Application.Current.MainWindow,
- WindowStartupLocation = WindowStartupLocation.CenterOwner
- };
- messageBox.Show();
- }
- }
- // break;
- // }
- }
- else
- {
- var errorEntriy = new ErrorEntity()
- {
- ReturnCode = bankResult.ReturnCode,
- ReturnDesc = bankResult.ReturnDesc,
- RequestFunc = Client_Resource.Function_BankUnBindBankCard
- };
- ErrorManager.ShowReturnError(errorEntriy,
- Muchinfo.MTPClient.Resources.Client_Resource.Bank_ErrotTips, true);
- }
- }));
- }
- private RelayCommand<SigningBank> _BankBingCardCommand;
- /// <summary>
- /// 绑银行卡
- /// </summary>
- public RelayCommand<SigningBank> BankBingCardCommand
- {
- get
- {
- return _BankBingCardCommand ?? (_BankBingCardCommand = new RelayCommand<SigningBank>((sign) =>
- {
- if (sign != null)
- {
- var bindCard = new BindCardView(sign) { ShowInTaskbar = false, Owner = Application.Current.MainWindow, WindowStartupLocation = WindowStartupLocation.CenterOwner };
- bindCard.ShowDialog();
- RefreshContent();
- }
- }));
- }
- }
- /// <summary>
- /// 解约操作
- /// </summary>
- public RelayCommand SignCommand
- {
- get
- {
- return new RelayCommand(() =>
- {
- var sign = new BankSigningView() { Owner = Application.Current.MainWindow, WindowStartupLocation = WindowStartupLocation.CenterOwner };
- sign.ShowDialog();
- });
- }
- }
- /// <summary>
- /// 修改手机号
- /// </summary>
- public RelayCommand ModifyPhoneCommand
- {
- get
- {
- return new RelayCommand(() =>
- {
- var sign = new MotifyPhoneView(CurrentSigningBank) { Owner = Application.Current.MainWindow, WindowStartupLocation = WindowStartupLocation.CenterOwner };
- sign.ShowDialog();
-
- });
- }
- }
- /// <summary>
- /// 查询资金信息
- /// </summary>
- public RelayCommand BalanceCommand
- {
- get
- {
- return new RelayCommand(() =>
- {
-
- if (CurrentSigningBank == null) return;
- var queryBank = new BankBalanceView(CurrentSigningBank) { Owner = Application.Current.MainWindow, WindowStartupLocation = WindowStartupLocation.CenterOwner };
- queryBank.ShowDialog();
- });
- }
- }
- private void UnSignBankCallback(BankSignResult result)
- {
- IsBusy = false;
- var bankDealStatus = result;
- RefreshContent();
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- if (result.ReturnCode == 0)
- {
- 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 = System.Windows.Application.Current.MainWindow,
- WindowStartupLocation = WindowStartupLocation.CenterOwner
- };
- messageBox.Show();
- }
- break;
- }
- }
- else
- {
- ErrorManager.ShowReturnError(bankDealStatus.ReturnCode, Muchinfo.MTPClient.Resources.Client_Resource.Bank_ErrotTips);
- }
-
- }));
- }
- #region
- public override void RegisterMessage()
- {
- RefreshContent();
- //当选择时刷新
- MessengerHelper.DefaultRegister<TradeAccount>(this, MessengerTokens.SignNotify, (e) =>
- {
- RefreshContent();
- });
- }
- /// <summary>
- /// 取消注册
- /// </summary>
- public override void UnRegisterMessage()
- {
- MessengerHelper.DefaultUnregister<TradeAccount>(this, MessengerTokens.SignNotify);
- base.UnRegisterMessage();
- }
- public override void RefreshContent()
- {
- var accountid = UserManager.CurrentTradeAccount.AccountId;
- //if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
- //{
- // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
- //}
- IsBusy = true;
- _bankService.QueryBankCustomerSignInfo(accountid, SearchBankCustomerSignCallback, ErrorCallback);
- }
- #endregion
- }
- }
|