| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- //----------------------------------------------------------------
- //Module Name: $safeprojectname$
- //Purpose:
- //CopyRight: Muchinfo
- //History:
- //----------------------------------------------------------------
- //DateTime 2016/3/24 15:58:45
- //Author
- //Description Create
- //----------------------------------------------------------------
- using Muchinfo.MTPClient.Data.Model;
- using tas;
- using Muchinfo.MTPClient.Adapter.Abstract;
- using Muchinfo.MTPClient.Adapter.Utilities;
- using Muchinfo.MTPClient.Data;
- using Muchinfo.MTPClient.Data.Enums;
- using Muchinfo.MTPClient.Data.Model.Account;
- using Muchinfo.MTPClient.Data.Model.Bank;
- using Bank;
- using System.Collections.ObjectModel;
- namespace Muchinfo.MTPClient.Adapter.ProtoBuf
- {
- public class BankProtobufAdapter : BankAdapter
- {
-
- public override byte[] ToRequestQueryCity(string provinceCode)
- {
- var city = new QueryCityInfoReq();
- city.Provinceid = provinceCode;
- city.flag = 1;
- return ProtoBufHelper.EntitySerialize(city);
- }
- public override ResponeEntity<List<City>> ToLocalCityInfo(object obj)
- {
- var buffer = obj as byte[];
- if (buffer == null)
- {
- throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
- }
- var rspData = ProtoBufHelper.EntityDeSerialize<QueryCityInfoRsp>(buffer);
- var resultEntity = new ResponeEntity<List<City>>()
- {
- RetCode = rspData.RetCode,
- RetMessage = rspData.RetDesc,
- Entity = new List<City>(),
- };
- if (rspData.Rsps == null || !rspData.Rsps.Any())
- {
- //todo:查询内容空
- return resultEntity;
- }
- foreach (var cityInfo in rspData.Rsps)
- {
- var city = new City();
- city.CityName = cityInfo.cityname;
- city.CityCode = cityInfo.cityid;
- city.ProvinceCoed = cityInfo.Provinceid;
- resultEntity.Entity.Add(city);
- }
- return resultEntity;
- }
- public override ResponeEntity<List<Province>> ToLocalProvinceInfo(object obj)
- {
- var buffer = obj as byte[];
- if (buffer == null)
- {
- throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
- }
- var rspData = new QueryProvinceInfoRsp();
- rspData = ProtoBufHelper.EntityDeSerialize<QueryProvinceInfoRsp>(buffer);
- var resultEntity = new ResponeEntity<List<Province>>()
- {
- RetCode = rspData.RetCode,
- RetMessage = rspData.RetDesc,
- Entity = new List<Province>(),
- };
- if (rspData.Rsps == null || !rspData.Rsps.Any())
- {
- //todo:查询内容空
- return resultEntity;
- }
- foreach (var provinceInfo in rspData.Rsps)
- {
- var province = new Province();
- province.ProvinceCode = provinceInfo.Provinceid;
- province.ProvinceName = provinceInfo.ProvinceName;
- resultEntity.Entity.Add(province);
- }
- return resultEntity;
- }
- public override byte[] ToRequestQueryProvince()
- {
- var province = new QueryProvinceInfoReq();
- province.flag = 1;
- return ProtoBufHelper.EntitySerialize(province);
- }
- #region 银行平台密钥申请
- public override byte[] ToBankCancelSignReq(SigningBank bankInfo )
- {
- var obj = new Bank.BankCancelSignReq()
- {
- ExtOperatorID = (long)bankInfo.ExtOperatorID,
- AccountCode = bankInfo.AccountCode,
- CustomerName = bankInfo.CusBankName,
- BankAccountNo = bankInfo.BankAccount,
- BankAccountName = bankInfo.AccountName,
- CertType = (int)bankInfo.CredentialType,
- CertID = bankInfo.CredentialNumber,
- CusBankID = bankInfo.CusBankID+string.Empty,
-
- //ExBankName =string.IsNullOrEmpty(bankInfo.Name)?string.Empty: bankInfo.Name,//"银行名字为必填字段"
- ExBankName = bankInfo.Name,//"银行名字为必填字段"
- ExBankNo = bankInfo.BankId,
- OpenBankNo = bankInfo.BranchId,
- PaymentNo = bankInfo.PaymentNumberVisibility ? bankInfo.PaymentNumber : string.Empty,
- ProtocolNo = bankInfo.ProtocolNumberVisibility? bankInfo.ProtocolNumber : string.Empty,
- AppDateTime = bankInfo.CurrentTime.ToString(),
- CustomerSignId = bankInfo.CustomerSignId,
- Currency = bankInfo.Currency,
- };
- return ProtoBufHelper.EntitySerialize(obj);
- }
- public override Bank.BankCancelSignRsp FromBankCancelSignRsp(object obj)
- {
- var buffer = obj as byte[];
- if (buffer == null)
- {
- throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
- }
- return ProtoBufHelper.EntityDeSerialize<Bank.BankCancelSignRsp>(buffer);
- }
- public override byte[] ToBankSignReq(tas.BankSignReq request)
- {
- return ProtoBufHelper.EntitySerialize(request);
- }
- public override tas.BankSignRsp FromBankSignRsp(object obj)
- {
- var buffer = obj as byte[];
- if (buffer == null)
- {
- throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
- }
- return ProtoBufHelper.EntityDeSerialize<tas.BankSignRsp>(buffer);
- }
- //public override byte[] ToSignUpdateReq(tas.SignUpdateReq request)
- //{
- // return ProtoBufHelper.EntitySerialize(request);
- //}
- public override Bank.SignUpdateRsp FromSignUpdateRsp(object obj)
- {
- var buffer = obj as byte[];
- if (buffer == null)
- {
- throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
- }
- return ProtoBufHelper.EntityDeSerialize<Bank.SignUpdateRsp>(buffer);
- }
-
- /// <summary>
- /// 银行平台密钥申请请求实体转换
- /// </summary>
- /// <param name="request">ApplySecretKeyRequest对象</param>
- /// <returns>返回ApplySecretKeyReq对象</returns>
- public override byte[] ToApplySecretKeyReq(EncryptKeyRequest request)
- {
- //var req = new tas.ApplySecretKeyReq()
- //{
- // //ExtOperatorID = request.ExtOperatorID,
- // CusBankId = request.CusBankId,
- // Currency = request.Currency,
- // KMCode = request.KMCode,
- //};
- //return ProtoBufHelper.EntitySerialize(req);
- return new byte[1024];
- }
- /// <summary>
- /// 银行平台密钥申请应答实体转换
- /// </summary>
- /// <param name="rsp">ApplySecretKeyRsp对象</param>
- /// <returns>返回EncryptKey对象</returns>
- public override Bank.ApplySecretKeyRsp FromApplySecretKeyResponse(object obj)
- {
- var buffer = obj as byte[];
- if (buffer == null)
- {
- throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
- }
- return ProtoBufHelper.EntityDeSerialize<Bank.ApplySecretKeyRsp>(buffer);
- }
- public override byte[] ToSignBankPwdReq(SignBankPDW request)
- {
- var req = new Bank.SignBankPwdReq()
- {
- ExtOperatorID = request.ExtOperatorID,
- ExchTicket = request.ExchTicket,
- AccountCode = request.AccountCode,
- CusBankId = request.CusBankId,
- Currency = request.Currency,
- BankAccountPWD = request.BankAccountPWD,
-
- };
- return ProtoBufHelper.EntitySerialize(req);
- }
- public override Bank.SignBankPwdInRsp FromSignBankPwdInRsp(object obj)
- {
- var buffer = obj as byte[];
- if (buffer == null)
- {
- throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
- }
- return ProtoBufHelper.EntityDeSerialize<Bank.SignBankPwdInRsp>(buffer);
- }
- public override BankSignResult FromSignBankPwdInRspToBankSignResult(Bank.BankDepositRsp result)
- {
- return new BankSignResult()
- {
- ExchTicket = result.ExchTicket,
- // Status = (BankDealStatus)result.Status,
- Status = (BankDealStatus)result.Status,
- ExtOperatorID = result.ExtOperatorID,
- WebAddress = Encoding.UTF8.GetString(Convert.FromBase64String(result.NetAddr)),
- ReturnCode = result.RetCode,
- ReturnDesc = result.RetDesc,
- };
- }
- public override BankSignResult FromBankSignRspToBankSignResult(tas.BankSignRsp result)
- {
- return null;
- // return new BankSignResult()
- // {
- // ExchTicket = result.ExchTicket,
- // // Status = (BankDealStatus)result.Status,
- // Status = (BankDealStatus)result.Status,
- // ExtOperatorID = result.ExtOperatorID,
- // WebAddress = Encoding.UTF8.GetString(Convert.FromBase64String(result.NetAddr)),
- // ReturnCode = result.RetCode,
- // ReturnDesc = result.RetDesc,
- // BankSubAccount = result.BankSubAcct,
- // };
- }
- public override byte[] ToBankWithDrawReq(Bank.BankWithDrawReq request)
- {
- return ProtoBufHelper.EntitySerialize(request);
- }
- public override Bank.BankWithDrawRsp FromBankWithDrawRsp(object obj)
- {
- var buffer = obj as byte[];
- if (buffer == null)
- {
- throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
- }
- return ProtoBufHelper.EntityDeSerialize<Bank.BankWithDrawRsp>(buffer);
- }
- public override byte[] ToBankDepositReq(Bank.BankDepositReq request)
- {
- return ProtoBufHelper.EntitySerialize(request);
- }
- public override Bank.BankDepositRsp FromBankDepositRsp(object obj)
- {
- var buffer = obj as byte[];
- if (buffer == null)
- {
- throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
- }
- return ProtoBufHelper.EntityDeSerialize<Bank.BankDepositRsp>(buffer);
- }
- #endregion
- public override byte[] ToIdentifyCodeReq(IdentifyCodeReq req)
- {
- //var serverReq = new tas.BankGetIdentifyCodeReq()
- //{
- // AccountCode = req.AccountCode,
- // Amount =Convert.ToDouble(req.Amount),
- // CusBankID = req.CusBankID,
- // CustomerSignId = req.CustomerSignId,
- // TradeType = (int)req.TradeType,
- // AccountType = (int)req.AccountType,
- // BankAccountNo = req.BankAccountNo,
- // BankCode =req.BankCode,
- // CardNum=req.CardNum,
- // CardType=(int)req.CardType,
- // Currency =req.Currency,
- // CustomerName=req.CustomerName,
- // MobilePhone=req.MobilePhone
- //};
- //return ProtoBufHelper.EntitySerialize(serverReq);
- return new byte[1024];
- }
- public override Bank.BankGetIdentifyCodeRsp FromIdentifyCodeReq(object obj)
- {
- var buffer = obj as byte[];
- if (buffer == null)
- {
- throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
- }
- return ProtoBufHelper.EntityDeSerialize<Bank.BankGetIdentifyCodeRsp>(buffer);
-
- }
- public override byte[] ToBankSubBalanceReq(SigningBank bankInfo)
- {
- //var serverReq = new tas.QueryBankAccountInfoReq()
- //{
- // AccountCode = bankInfo.AccountCode,
-
- // Cusbankid = bankInfo.CusBankID+string.Empty,
-
- // AccountType = 32+string.Empty, ////查询余额的账号类型是32
-
- //};
- //return ProtoBufHelper.EntitySerialize(serverReq);
- return new byte[1024];
- }
- public override ResponeEntity<List<BankBalanceModel>> FromoBankSubBalanceRsp(object obj)
- {
- return new ResponeEntity<List<BankBalanceModel>>();
- //var buffer = obj as byte[];
- //if (buffer == null)
- //{
- // throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
- //}
- //var bankBalanceModels = new List<BankBalanceModel>();
- //var bankAccountRsp= ProtoBufHelper.EntityDeSerialize<tas.QueryBankAccountInfoRsp>(buffer);
- //var resultEntity = new ResponeEntity<List<BankBalanceModel>>()
- //{
- // RetCode = bankAccountRsp.RetCode,
- // RetMessage = bankAccountRsp.RetDesc,
-
- //};
- //if ( bankAccountRsp.Rsps != null)
- //{
- // foreach (var bankBalance in bankAccountRsp.Rsps)
- // {
- // var balance = new BankBalanceModel()
- // {
- // AccountCode = bankBalance.AccountCode,
- // AccountType = bankBalance.AccountType,
- // BankBalance = bankBalance.BankBalance,
- // Cusbankid = bankBalance.Cusbankid,
- // ExchTicket = bankBalance.ExchTicket,
- // PlatBalance = bankBalance.PlatBalance,
- // };
- // bankBalanceModels.Add(balance);
- // }
- // resultEntity.Entity = bankBalanceModels;
- //}
- //return resultEntity;
- }
- public override byte[] ToBankRebindCardReq(SigningBank bankRebind)
- {
- //var Req = new tas.BankRebindCardReq()
- //{
-
- // ExtOperatorID = bankRebind.ExtOperatorID,
- // AccountCode = bankRebind.AccountCode,
- // BankAccountNo = bankRebind.BankAccount,
- // BankAccountName = bankRebind.AccountName,
- // CertType = (int)bankRebind.CredentialType,
- // CertID = string.IsNullOrWhiteSpace(bankRebind.CredentialNumber) ? "0000" : bankRebind.CredentialNumber,
- // CusBankID = bankRebind.CusBankID + string.Empty,
- // CustomerName = bankRebind.CustomerName,
- // ExBankNo = bankRebind.BankId,
- // ExBankName = bankRebind.Name,
- // OpenBankNo = bankRebind.BranchId,
- // OpenBankName = bankRebind.BranchBankName,
- // PaymentNo = bankRebind.PaymentNumber,
- // ProtocolNo = bankRebind.ProtocolNumber,
- // AccountType = (int)bankRebind.AccountType,
- // Currency = string.IsNullOrWhiteSpace(bankRebind.Currency) ? "RMB" : bankRebind.Currency,
- // BankAccountPWD = string.IsNullOrEmpty(bankRebind.BankPassword) ? string.Empty : bankRebind.BankPassword,
- // //BankAccountPWD = bankRebind.BankPassword,
- // //SerialNumber = request.SerialNumber
- // // BankAccountPWD = request.BankAccountPWD,
- // IdentifyCode = bankRebind.IdentifyCode,
- // AgentCertID = bankRebind.AgentCID,
- // AgentCertType = (int)bankRebind.AgentCredentialType,
- // AgentName = bankRebind.AgentName,
- // BankAccountType = (int)bankRebind.BankAccountType,
- // BankCity = bankRebind.CityCode,
- // BankProvince = bankRebind.ProvinceCode,
- // MobilePhone = bankRebind.MobilePhone,
- // BankCardType = bankRebind.BankCardType == 0 ? 1 : (int)bankRebind.BankCardType,
- // RebindToNewBankCardNo = bankRebind.RebindToNewBankCardNo,
- // RebindToNewBankCardNoAccName = bankRebind.RebindToNewBankCardNoAccName,
- // RebindToNewBankNo = bankRebind.RebindToNewBankNo,
- //};
- //return ProtoBufHelper.EntitySerialize(Req);
- return new byte[1024];
- }
- public override byte[] ToBankUnBindCardReq(SigningBank bankunbind)
- {
- //var Req = new tas.BankUnbindCardReq()
- //{
- // ExtOperatorID = bankunbind.ExtOperatorID,
- // AccountCode = bankunbind.AccountCode,
- // BankAccountNo = bankunbind.BankAccount,
- // BankAccountName = bankunbind.AccountName,
-
- // CusBankID = bankunbind.CusBankID + string.Empty,
-
- // ExBankNo = bankunbind.BankId,
- // ExBankName = bankunbind.Name,
-
- // AccountType = (int)bankunbind.AccountType,
- // Currency = string.IsNullOrWhiteSpace(bankunbind.Currency) ? "RMB" : bankunbind.Currency,
- // AppDateTime = bankunbind.AppDateTime,
- // ExchId = bankunbind.ExchId
- // //BankAccountPWD = bankRebind.BankPassword,
- // //SerialNumber = request.SerialNumber
- // // BankAccountPWD = request.BankAccountPWD,
-
- //};
- //return ProtoBufHelper.EntitySerialize(Req);
- return new byte[1024];
- }
- public override ResponeEntity<BankSignResult> ToBankReBindCardRsp(object obj)
- {
- return new ResponeEntity<BankSignResult>();
- //var buffer = obj as byte[];
- //if (buffer == null)
- //{
- // throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
- //}
- //var rspData = ProtoBufHelper.EntityDeSerialize<BankUnbindCardRsp>(buffer);
- //return new ResponeEntity<BankSignResult>()
- //{
- // RetCode = rspData.RetCode,
- // RetMessage = rspData.RetDesc,
- // Entity = new BankSignResult()
- // {
- // ReturnCode = rspData.RetCode,
- // ReturnDesc = rspData.RetDesc,
- // WebAddress =string.IsNullOrEmpty(rspData.NetAddr) ?"":Encoding.UTF8.GetString(Convert.FromBase64String(rspData.NetAddr)),
- // ExchTicket = rspData.ExchTicket,
- // Status = (BankDealStatus)rspData.Status,
- // },
- //};
- }
- public override ResponeEntity<BankUnBindResult> ToBankUnBindCardRsp(object obj)
- {
- return new ResponeEntity<BankUnBindResult>();
- // var buffer = obj as byte[];
- //if (buffer == null)
- //{
- // throw new Exception(System.Reflection.MethodBase.GetCurrentMethod().Name + "进行反序列化对象内容为空!");
- //}
- //var rspData = ProtoBufHelper.EntityDeSerialize<BankUnbindCardRsp>(buffer);
- //return new ResponeEntity<BankUnBindResult>()
- //{
- // RetCode = rspData.RetCode,
- // RetMessage = rspData.RetDesc,
- // Entity = new BankUnBindResult()
- // {
- // ReturnCode = rspData.RetCode,
- // ReturnDesc = rspData.RetDesc,
- // WebAddress = string.IsNullOrEmpty(rspData.NetAddr) ? "" : Encoding.UTF8.GetString(Convert.FromBase64String(rspData.NetAddr)),
-
- // ExchTicket = rspData.ExchTicket,
- // Status = (BankDealStatus)rspData.Status,
- // },
- //};
-
- }
- }
- }
|