public void Setup() { Repo = new BizCustomerRepository(DataAccess) { User = SystemOperator.SysOperator }; }
/// <summary> /// /// </summary> /// <param name="modelSources"></param> void IImportData.CreateData(IList modelSources) { List <dynamic> models = modelSources as List <dynamic>; using BizCustomerRepository bizCustRepo = new BizCustomerRepository(DataAccess) { Message = Message }; using ReceiptBillRepository repo = new ReceiptBillRepository(DataAccess) { User = SystemOperator.SysOperator }; List <ChannelMapModel> channelMap = DataAccess.Set <ChannelMapModel>().ToList(); models.ForEach(model => { if (model is ReceiptInfoBillMarketModel) { repo.Create(BizReceiptInfo.GetReceiptBillSet(model, channelMap)); } else if (model is ReceiptInfoBillMarketSPIModel) { repo.Create(BizReceiptInfo.GetReceiptBillSet(model, channelMap)); } }); repo.CommitData(FuncAction.Create); }
/// <summary> /// 根據銷帳編號獲取商戶資料 /// </summary> /// <param name="compareCode"></param> /// <param name="compareCodeForCheck"></param> /// <returns></returns> private static BizCustomerSet GetBizCustomerSet(ApplicationDbContext dataAccess, Dictionary <string, BizCustomerSet> BizCustSetDic, string compareCode) { compareCode = compareCode.TrimStart('0'); BizCustomerSet bizCust = null; string custCode6 = compareCode.Substring(0, 6), custCode4 = compareCode.Substring(0, 4), custCode3 = compareCode.Substring(0, 3); if (null == bizCust && BizCustSetDic.ContainsKey(custCode6)) { bizCust = BizCustSetDic[custCode6]; } if (null == bizCust && BizCustSetDic.ContainsKey(custCode4)) { bizCust = BizCustSetDic[custCode4]; } if (null == bizCust && BizCustSetDic.ContainsKey(custCode3)) { bizCust = BizCustSetDic[custCode3]; } if (null == bizCust) { using BizCustomerRepository biz = new BizCustomerRepository(dataAccess); if (null == bizCust) { bizCust = biz.QueryData(new object[] { custCode6 }); if (null != bizCust) { BizCustSetDic.Add(custCode6, bizCust); } } if (null == bizCust) { bizCust = biz.QueryData(new object[] { custCode4 }); if (null != bizCust) { BizCustSetDic.Add(custCode4, bizCust); } } if (null == bizCust) { bizCust = biz.QueryData(new object[] { custCode3 }); if (null != bizCust) { BizCustSetDic.Add(custCode3, bizCust); } } } return(bizCust); }
/// <summary> /// 新增資料 /// </summary> /// <param name="modelSources"></param> void IImportData.CreateData(IList modelSources) { List <ReceiptInfoBillPostModel> models = modelSources as List <ReceiptInfoBillPostModel>; using BizCustomerRepository bizCustRepo = new BizCustomerRepository(DataAccess) { Message = Message }; using ReceiptBillRepository repo = new ReceiptBillRepository(DataAccess) { Message = Message, User = SystemOperator.SysOperator }; List <ChannelMapModel> channelMap = DataAccess.Set <ChannelMapModel>().ToList(); foreach (ReceiptInfoBillPostModel model in models) { repo.Create(BizReceiptInfo.GetReceiptBillSet(model, channelMap)); } repo.CommitData(FuncAction.Create); }
private static void BizCustomer(SysMessageLog Message, ApplicationDbContext DataAccess) { try { Message.Prefix = "新增「商戶」-初始資料:"; using BizCustomerRepository repo = new BizCustomerRepository(DataAccess) { User = SystemOperator.SysOperator, Message = Message }; List <BizCustomerSet> custs = new List <BizCustomerSet>() { new BizCustomerSet() { BizCustomer = new BizCustomerModel() { CustomerCode = "445235", CustomerId = "48577921", AccountDeptId = "0019", RealAccount = "7714815486840", VirtualAccountLen = VirtualAccountLen.Len13, BillTermLen = 2, PayerNoLen = 5, VirtualAccount1 = VirtualAccount1.BillTerm, VirtualAccount2 = VirtualAccount2.PayerNo, VirtualAccount3 = VirtualAccount3.NoverifyCode, BizCustType = BizCustType.Introducer, ChannelIds = "00,01,02,03,04,05,12,13,14", CollectionTypeIds = LibData.Merge(",", false, SystemCP.BankCollectionTypeId, SystemCP.PostCollectionTypeId, "6V1,6V2,6V3"), AccountStatus = AccountStatus.Enable, ImportBatchNo = "BeginData" }, BizCustomerFeeDetail = new List <BizCustomerFeeDetailModel>() { new BizCustomerFeeDetailModel() { CustomerCode = "445235", ChannelGroupType = ChannelGroupType.Bank, BankFeeType = BankFeeType.ClearFee_CurMonth, Fee = 15, IntroPercent = 0 }, new BizCustomerFeeDetailModel() { CustomerCode = "445235", ChannelGroupType = ChannelGroupType.Market, BankFeeType = BankFeeType.ClearFee_CurMonth, Fee = 15, IntroPercent = 0 }, new BizCustomerFeeDetailModel() { CustomerCode = "445235", ChannelGroupType = ChannelGroupType.Post, BankFeeType = BankFeeType.ClearFee_CurMonth, Fee = 15, IntroPercent = 0 }, } }, new BizCustomerSet() { BizCustomer = new BizCustomerModel() { CustomerCode = "774336", CustomerId = "77494941", AccountDeptId = "0019", RealAccount = "7714815486840", VirtualAccountLen = VirtualAccountLen.Len13, BillTermLen = 2, PayerNoLen = 5, VirtualAccount1 = VirtualAccount1.BillTerm, VirtualAccount2 = VirtualAccount2.PayerNo, VirtualAccount3 = VirtualAccount3.NoverifyCode, BizCustType = BizCustType.Hitrust, ChannelIds = "00,01,02,03,04,05,12,13,14", CollectionTypeIds = LibData.Merge(",", false, SystemCP.BankCollectionTypeId, SystemCP.PostCollectionTypeId, "6V1,6V2,6V3"), AccountStatus = AccountStatus.Enable, ImportBatchNo = "BeginData" }, BizCustomerFeeDetail = new List <BizCustomerFeeDetailModel>() { new BizCustomerFeeDetailModel() { CustomerCode = "774336", ChannelGroupType = ChannelGroupType.Bank, BankFeeType = BankFeeType.ClearFee_CurMonth, Fee = 15, IntroPercent = 0 }, new BizCustomerFeeDetailModel() { CustomerCode = "774336", ChannelGroupType = ChannelGroupType.Market, BankFeeType = BankFeeType.ClearFee_CurMonth, Fee = 15, IntroPercent = 0 }, new BizCustomerFeeDetailModel() { CustomerCode = "774336", ChannelGroupType = ChannelGroupType.Post, BankFeeType = BankFeeType.ClearFee_CurMonth, Fee = 15, IntroPercent = 0 }, } }, new BizCustomerSet() { BizCustomer = new BizCustomerModel() { CustomerCode = "992086", CustomerId = "30262944", AccountDeptId = "0019", RealAccount = "0514101002570", VirtualAccountLen = VirtualAccountLen.Len13, BillTermLen = 3, PayerNoLen = 4, VirtualAccount1 = VirtualAccount1.BillTerm, VirtualAccount2 = VirtualAccount2.PayerNo, VirtualAccount3 = VirtualAccount3.NoverifyCode, ChannelIds = "00,01,02,03,04,05,12,13,14", CollectionTypeIds = LibData.Merge(",", false, SystemCP.BankCollectionTypeId, SystemCP.PostCollectionTypeId, "6V1,6V2,6V3"), BizCustType = BizCustType.Cust, AccountStatus = AccountStatus.Enable, ImportBatchNo = "BeginData" }, BizCustomerFeeDetail = new List <BizCustomerFeeDetailModel>() { new BizCustomerFeeDetailModel() { CustomerCode = "992086", ChannelGroupType = ChannelGroupType.Bank, BankFeeType = BankFeeType.ClearFee_NextMonth, Fee = 15, IntroPercent = 0 }, new BizCustomerFeeDetailModel() { CustomerCode = "992086", ChannelGroupType = ChannelGroupType.Market, BankFeeType = BankFeeType.ClearFee_NextMonth, Fee = 15, IntroPercent = 0 }, new BizCustomerFeeDetailModel() { CustomerCode = "992086", ChannelGroupType = ChannelGroupType.Post, BankFeeType = BankFeeType.ClearFee_NextMonth, Fee = 15, IntroPercent = 0 }, } }, new BizCustomerSet() { BizCustomer = new BizCustomerModel() { CustomerCode = "2143", CustomerId = "00146877", AccountDeptId = "0019", RealAccount = "0518425007840", VirtualAccountLen = VirtualAccountLen.Len16, BillTermLen = 6, PayerNoLen = 6, VirtualAccount1 = VirtualAccount1.BillTerm, VirtualAccount2 = VirtualAccount2.PayerNo, VirtualAccount3 = VirtualAccount3.NoverifyCode, IntroCustomerCode = "445235", ChannelIds = "00,01,02,03,04,05,12,13,14", CollectionTypeIds = LibData.Merge(",", false, SystemCP.BankCollectionTypeId, SystemCP.PostCollectionTypeId, "6V1,6V2,6V3"), BizCustType = BizCustType.Cust, AccountStatus = AccountStatus.Enable, ImportBatchNo = "BeginData" }, BizCustomerFeeDetail = new List <BizCustomerFeeDetailModel>() { new BizCustomerFeeDetailModel() { CustomerCode = "2143", ChannelGroupType = ChannelGroupType.Bank, BankFeeType = BankFeeType.TotalFee, Fee = 35, IntroPercent = 0 }, new BizCustomerFeeDetailModel() { CustomerCode = "2143", ChannelGroupType = ChannelGroupType.Market, BankFeeType = BankFeeType.TotalFee, Fee = 35, IntroPercent = 0 }, new BizCustomerFeeDetailModel() { CustomerCode = "2143", ChannelGroupType = ChannelGroupType.Post, BankFeeType = BankFeeType.TotalFee, Fee = 35, IntroPercent = 0 }, } }, new BizCustomerSet() { BizCustomer = new BizCustomerModel() { CustomerCode = "805", CustomerId = "01031142", AccountDeptId = "0019", RealAccount = "7714815486840", VirtualAccountLen = VirtualAccountLen.Len14, BillTermLen = 5, PayerNoLen = 6, VirtualAccount1 = VirtualAccount1.BillTerm, VirtualAccount2 = VirtualAccount2.PayerNo, VirtualAccount3 = VirtualAccount3.NoverifyCode, BizCustType = BizCustType.Cust, IntroCustomerCode = "445235", ChannelIds = "00,01,02,03,04,05,12,13,14", CollectionTypeIds = LibData.Merge(",", false, SystemCP.BankCollectionTypeId, SystemCP.PostCollectionTypeId, "6V1,6V2,6V3"), AccountStatus = AccountStatus.Enable, ImportBatchNo = "BeginData" }, BizCustomerFeeDetail = new List <BizCustomerFeeDetailModel>() { new BizCustomerFeeDetailModel() { CustomerCode = "805", ChannelGroupType = ChannelGroupType.Bank, BankFeeType = BankFeeType.TotalFee, Fee = 28, IntroPercent = 50 }, new BizCustomerFeeDetailModel() { CustomerCode = "805", ChannelGroupType = ChannelGroupType.Market, BankFeeType = BankFeeType.TotalFee, Fee = 28, IntroPercent = 50 }, new BizCustomerFeeDetailModel() { CustomerCode = "805", ChannelGroupType = ChannelGroupType.Post, BankFeeType = BankFeeType.TotalFee, Fee = 28, IntroPercent = 50 }, } }, new BizCustomerSet() { BizCustomer = new BizCustomerModel() { CustomerCode = "993586", CustomerId = "00973171", AccountDeptId = "0019", RealAccount = "7714815486840", VirtualAccountLen = VirtualAccountLen.Len13, BillTermLen = 2, PayerNoLen = 5, VirtualAccount1 = VirtualAccount1.BillTerm, VirtualAccount2 = VirtualAccount2.PayerNo, VirtualAccount3 = VirtualAccount3.NoverifyCode, BizCustType = BizCustType.Cust, ChannelIds = "00,01,02,03,04,05,12,13,14", CollectionTypeIds = LibData.Merge(",", false, SystemCP.BankCollectionTypeId, SystemCP.PostCollectionTypeId, "6V1,6V2,6V3"), AccountStatus = AccountStatus.Enable, ImportBatchNo = "BeginData" }, BizCustomerFeeDetail = new List <BizCustomerFeeDetailModel>() { new BizCustomerFeeDetailModel() { CustomerCode = "993586", ChannelGroupType = ChannelGroupType.Bank, BankFeeType = BankFeeType.ClearFee_CurMonth, Fee = 15, IntroPercent = 0 }, new BizCustomerFeeDetailModel() { CustomerCode = "993586", ChannelGroupType = ChannelGroupType.Market, BankFeeType = BankFeeType.ClearFee_CurMonth, Fee = 15, IntroPercent = 0 }, new BizCustomerFeeDetailModel() { CustomerCode = "993586", ChannelGroupType = ChannelGroupType.Post, BankFeeType = BankFeeType.ClearFee_CurMonth, Fee = 15, IntroPercent = 0 }, } }, }; custs.ForEach(cust => { if (null == repo.QueryData(new[] { cust.BizCustomer.CustomerCode })) { repo.Create(cust); } }); repo.CommitData(FuncAction.Create); } finally { Message.Prefix = string.Empty; } }
/// <summary> /// 獲取客戶資料 /// </summary> /// <param name="model"></param> /// <param name="bizCustomerSet"></param> /// <param name="customerSet"></param> private void GetCustomerInfo(ACCFTT model, BizCustomerRepository bizCustRepo, CustomerRepository custRepo, CustUserRepository custUserRepo, out BizCustomerSet bizCustomerSet, out CustomerSet customerSet, out CustUserSet custUserSet) { bizCustomerSet = bizCustRepo.QueryData(new object[] { model.KEYNO }); customerSet = custRepo.QueryData(new object[] { model.IDCODE.TrimStart('0') }); custUserSet = custUserRepo.QueryData(new object[] { $"{model.IDCODE.TrimStart('0')},admin" }); }
/// <summary> /// 導入商戶資料 /// </summary> /// <param name="modelSources"></param> void IImportData.CreateData(IList modelSources) { List <ACCFTT> srcs = modelSources as List <ACCFTT>; if (null == srcs) { return; } using BizCustomerRepository bizCustRepo = new BizCustomerRepository(DataAccess) { Message = Message, User = SystemOperator.SysOperator }; using CustomerRepository custRepo = new CustomerRepository(DataAccess) { Message = Message, User = SystemOperator.SysOperator }; using CustUserRepository custUserRepo = new CustUserRepository(DataAccess) { Message = Message, User = SystemOperator.SysOperator }; foreach (ACCFTT model in srcs) { Message.Prefix = $"第{model.Id}行:"; switch (model.APPLYSTAT.ToInt32()) { case 0: { DataAccess.Database.BeginTransaction(); try { GetCustomerInfo(model, bizCustRepo, custRepo, custUserRepo, out BizCustomerSet bizCustomerSet, out CustomerSet customerSet, out CustUserSet custUserSet); if (customerSet is null) { custRepo.Create(BizACCFTT.SetCustomer(model, customerSet)); } else { custRepo.Update(null, BizACCFTT.SetCustomer(model, customerSet)); } custRepo.CommitData(FuncAction.Create); if (bizCustomerSet is null) { bizCustRepo.Create(BizACCFTT.SetBizCustomer(model, bizCustomerSet)); } else { bizCustRepo.Update(null, BizACCFTT.SetBizCustomer(model, bizCustomerSet)); } bizCustRepo.CommitData(FuncAction.Create); if (custUserSet is null) { custUserRepo.Create(BizACCFTT.AddAdminAccount(model)); custUserRepo.CommitData(FuncAction.Create); } DataAccess.Database.CommitTransaction(); } catch { DataAccess.Database.RollbackTransaction(); throw; } } break; case 1: case 9: UnableBizCustomer(model.KEYNO); break; } } }