public void C_CorrectData_3_1() { BizCustomerSet expectData = new BizCustomerSet() { BizCustomer = new BizCustomerModel() { MarketEnable = true, PostEnable = true, }, BizCustomerFeeDetail = new List <BizCustomerFeeDetailModel>() { new BizCustomerFeeDetailModel() { IntroPercent = 0 }, new BizCustomerFeeDetailModel() { IntroPercent = 0 }, new BizCustomerFeeDetailModel() { IntroPercent = 0 }, }, }, actualData = Repo.Create(new BizCustomerSet() { BizCustomer = new BizCustomerModel() { CustomerId = "64487252", CustomerCode = "805", VirtualAccountLen = VirtualAccountLen.Len14, BillTermLen = 5, PayerNoLen = 6, BizCustType = BizCustType.Cust, VirtualAccount1 = VirtualAccount1.BillTerm, VirtualAccount2 = VirtualAccount2.PayerNo, VirtualAccount3 = VirtualAccount3.NoverifyCode, ChannelIds = "00,01,02,03,04,05", CollectionTypeIds = $"{SystemCP.BankCollectionTypeId},{SystemCP.PostCollectionTypeId},6V1,6V2,6V3", AccountStatus = AccountStatus.Enable, }, BizCustomerFeeDetail = new List <BizCustomerFeeDetailModel>() { new BizCustomerFeeDetailModel() { CustomerCode = "805", ChannelGroupType = ChannelGroupType.Bank, BankFeeType = BankFeeType.ClearFee_NextMonth, Fee = 10, IntroPercent = 0 }, new BizCustomerFeeDetailModel() { CustomerCode = "805", ChannelGroupType = ChannelGroupType.Market, BankFeeType = BankFeeType.ClearFee_NextMonth, Fee = 10, IntroPercent = 0 }, new BizCustomerFeeDetailModel() { CustomerCode = "805", ChannelGroupType = ChannelGroupType.Post, BankFeeType = BankFeeType.ClearFee_NextMonth, Fee = 10, IntroPercent = 0 }, } }); AssertCorrectData(expectData, actualData); }
/// <summary> /// /// </summary> /// <param name="expectData"></param> /// <param name="actualData"></param> private void AssertSet(BizCustomerSet expectData, BizCustomerSet actualData) { Assert.AreEqual(expectData.BizCustomer.MarketEnable, actualData.BizCustomer.MarketEnable, ResxManage.GetDescription <BizCustomerModel>(p => p.MarketEnable)); Assert.AreEqual(expectData.BizCustomer.PostEnable, actualData.BizCustomer.PostEnable, ResxManage.GetDescription <BizCustomerModel>(p => p.PostEnable)); for (int i = 0; i < expectData.BizCustomerFeeDetail.Count; i++) { Assert.AreEqual(expectData.BizCustomerFeeDetail[i].IntroPercent, actualData.BizCustomerFeeDetail[i].IntroPercent); } }
/// <summary> /// 設置欄位值 /// </summary> /// <param name="set"></param> /// <param name="action"></param> public static void SetData(ReceiptBillSet set, ApplicationDbContext dataAccess, Dictionary <string, BizCustomerSet> bizCustSetDic, Dictionary <string, CollectionTypeSet> colSetDic, Dictionary <DateTime, bool> workDic) { BizCustomerSet bizCustomerSet = GetBizCustomerSet(dataAccess, bizCustSetDic, set.ReceiptBill.VirtualAccountCode); CollectionTypeSet collectionTypeSet = GetCollectionTypeSet(dataAccess, colSetDic, set.ReceiptBill.CollectionTypeId); SetBizCustomer(set.ReceiptBill, bizCustomerSet.BizCustomer); SetBillNo(dataAccess, set.ReceiptBill); SetFee(set.ReceiptBill, bizCustomerSet, collectionTypeSet); SetRemitDate(set.ReceiptBill, collectionTypeSet, workDic); SetErrMessage(set.ReceiptBill); }
/// <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="set"></param> private static void CheckBizCustType(SysMessageLog message, BizCustomerSet set) { if (set.BizCustomerFeeDetail.Any(p => p.BankFeeType == BankFeeType.Hitrust_ClearFee_CurMonth || p.BankFeeType == BankFeeType.Hitrust_ClearFee_NextMonth)) { if (set.BizCustomer.IntroCustomerCode.IsNullOrEmpty() || set.BizCustomer.IntroCustomer.BizCustType != BizCustType.Hitrust) { message.AddCustErrorMessage(MessageCode.Code1019, ResxManage.GetDescription(BizCustType.Hitrust)); } } if (set.BizCustomerFeeDetail.Any(p => p.BankFeeType == BankFeeType.TotalFee && p.IntroPercent > 0m)) { if (set.BizCustomer.IntroCustomerCode.IsNullOrEmpty() || set.BizCustomer.IntroCustomer.BizCustType != BizCustType.Introducer) { message.AddCustErrorMessage(MessageCode.Code1019, ResxManage.GetDescription(BizCustType.Introducer)); } } }
/// <summary> /// 設置資料 /// </summary> /// <param name="set"></param> public static void SetData(BizCustomerSet set) { bool marketEnable = false, postEnable = false; set.BizCustomerFeeDetail.ForEach(row => { if (row.ChannelGroupType == ChannelGroupType.Market) { marketEnable = true; } if (row.ChannelGroupType == ChannelGroupType.Post) { postEnable = true; } ResetRowPercent(row); }); set.BizCustomer.MarketEnable = marketEnable; set.BizCustomer.PostEnable = postEnable; }
/// <summary> /// 設置費用 /// </summary> private static void SetFee(ReceiptBillModel receiptBill, BizCustomerSet bizCustomerSet, CollectionTypeSet collectionTypeSet) { CollectionTypeDetailModel collectionTypeDetailModel = collectionTypeSet.CollectionTypeDetail.FirstOrDefault(p => p.ChannelId.Equals(receiptBill.ChannelId) && (p.SRange <= receiptBill.PayAmount && p.ERange >= receiptBill.PayAmount)); BizCustomerFeeDetailModel bizCustomerFeeDetailModel = bizCustomerSet.BizCustomerFeeDetail.FirstOrDefault(p => p.ChannelGroupType.Equals(receiptBill.Channel.ChannelGroupType)); BizCustomerFeeDetailModel hiTrust = bizCustomerSet.BizCustomerFeeDetail.FirstOrDefault(p => p.BankFeeType.Equals(BankFeeType.Hitrust_ClearFee_CurMonth) || p.BankFeeType.Equals(BankFeeType.Hitrust_ClearFee_NextMonth)); receiptBill.ChargePayType = collectionTypeSet.CollectionType.ChargePayType; receiptBill.BankFeeType = bizCustomerFeeDetailModel.BankFeeType; if (receiptBill.BankFeeType.Equals(BankFeeType.TotalFee)) { switch (receiptBill.CollectionType.ChargePayType) { case ChargePayType.Deduction: { receiptBill.ThirdFee = FeeDeduct(bizCustomerFeeDetailModel.Fee, collectionTypeDetailModel.ChannelTotalFee, bizCustomerFeeDetailModel.IntroPercent); receiptBill.BankFee = bizCustomerFeeDetailModel.Fee - receiptBill.ThirdFee; } break; case ChargePayType.Increase: { receiptBill.ThirdFee = FeePlus(bizCustomerFeeDetailModel.Fee, bizCustomerFeeDetailModel.IntroPercent); receiptBill.BankFee = bizCustomerFeeDetailModel.Fee - receiptBill.ThirdFee; } break; } } else { receiptBill.BankFee = bizCustomerFeeDetailModel.Fee; receiptBill.ThirdFee = 0m; } receiptBill.ThirdFee = null != hiTrust ? hiTrust.IntroPercent : receiptBill.ThirdFee; receiptBill.ChannelFeedBackFee = collectionTypeDetailModel.ChannelFeedBackFee; receiptBill.ChannelRebateFee = collectionTypeDetailModel.ChannelRebateFee; receiptBill.ChannelFee = collectionTypeDetailModel.ChannelFee; receiptBill.ChannelTotalFee = collectionTypeDetailModel.ChannelTotalFee; receiptBill.TotalFee = receiptBill.BankFeeType.Equals(BankFeeType.TotalFee) ? bizCustomerFeeDetailModel.Fee : collectionTypeDetailModel.ChannelTotalFee; }
/// <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="expectData"></param> /// <param name="actualData"></param> /// <param name="messageLog"></param> private void AssertCorrectData(BizCustomerSet expectData, BizCustomerSet actualData) { AssertSet(expectData, actualData); AssertMessage(); }
/// <summary> /// 服務申請書對應商戶資料 /// </summary> /// <param name="accftt"></param> public static BizCustomerSet SetBizCustomer(ACCFTT accftt, BizCustomerSet bizCustomerSet) { if (null == bizCustomerSet) { bizCustomerSet = new BizCustomerSet(); } if (null == bizCustomerSet.BizCustomer) { bizCustomerSet.BizCustomer = new BizCustomerModel(); } if (null == bizCustomerSet.BizCustomerFeeDetail) { bizCustomerSet.BizCustomerFeeDetail = new List <BizCustomerFeeDetailModel>(); } string custId = accftt.IDCODE.TrimStart('0'); string custCode = accftt.KEYNO.Trim(); bizCustomerSet.BizCustomer.CustomerId = custId; bizCustomerSet.BizCustomer.CustomerCode = custCode; bizCustomerSet.BizCustomer.AccountDeptId = accftt.BRCODE; bizCustomerSet.BizCustomer.RealAccount = accftt.ACCIDNO; //bizCustomerSet.BizCustomer.VirtualAccountLen = (10 + custCode.Length).ToByte(); bizCustomerSet.BizCustomer.ChannelIds = GetChannel(accftt); bizCustomerSet.BizCustomer.CollectionTypeIds = GetCollectionType(accftt); #if DEBUG bizCustomerSet.BizCustomer.VirtualAccount1 = VirtualAccount1.BillTerm; bizCustomerSet.BizCustomer.VirtualAccount2 = VirtualAccount2.PayerNo; #endif bizCustomerSet.BizCustomer.VirtualAccount3 = GetVirtualAccount3(accftt); bizCustomerSet.BizCustomer.AccountStatus = AccountStatus.Unable; //bizCustomerSet.BizCustomer.EntrustCustId = accftt.CUSTID; bizCustomerSet.BizCustomer.ImportBatchNo = accftt.ImportBatchNo; bizCustomerSet.BizCustomer.Source = accftt.Src; //int rowId = bizCustomerSet.BizCustomerFeeDetail.OrderBy(p => -p.RowId).Select(p => p.RowId).FirstOrDefault(); bizCustomerSet.BizCustomerFeeDetail.ForEach(p => p.RowState = RowState.Delete); if (!accftt.ACTFEE.ToInt32().IsNullOrEmpty()) { bizCustomerSet.BizCustomerFeeDetail.Add(new BizCustomerFeeDetailModel() { CustomerCode = custCode, RowState = RowState.Insert, ChannelGroupType = ChannelGroupType.Market, BankFeeType = BankFeeType.ClearFee_NextMonth, Fee = accftt.ACTFEE.ToDecimal(), IntroPercent = 0m }); } if (!accftt.ACTFEEPT.ToInt32().IsNullOrEmpty()) { bizCustomerSet.BizCustomerFeeDetail.Add(new BizCustomerFeeDetailModel() { CustomerCode = custCode, RowState = RowState.Insert, ChannelGroupType = ChannelGroupType.Post, BankFeeType = BankFeeType.ClearFee_NextMonth, Fee = accftt.ACTFEEPT.ToDecimal(), IntroPercent = 0m, }); } if (!accftt.HIFLAG.IsNullOrEmpty()) { //bizCustomerSet.BizCustomer.HiTrustFlag = (HiTrustFlag)accftt.HIFLAG.ToByte(); } if (!accftt.HIFARE.IsNullOrEmpty()) { bizCustomerSet.BizCustomerFeeDetail.Add(new BizCustomerFeeDetailModel() { CustomerCode = custCode, RowState = RowState.Insert, //ChannelType = ChannelGroupType.HiTrust, //BankFeeType = BankFeeType.HitrustFee, Fee = accftt.HIFARE.ToDecimal(), IntroPercent = 0m, }); } //銀行-每筆總手續費 if (!accftt.ACTFEEBEFT.IsNullOrEmpty()) { bizCustomerSet.BizCustomerFeeDetail.Add(new BizCustomerFeeDetailModel() { CustomerCode = custCode, RowState = RowState.Insert, ChannelGroupType = ChannelGroupType.Bank, BankFeeType = BankFeeType.TotalFee, Fee = accftt.ACTFEEBEFT.ToDecimal(), IntroPercent = accftt.SHAREBEFTPERCENT.ToDecimal(), }); } //超商-每筆總手續費 if (!accftt.ACTFEEMART.IsNullOrEmpty()) { bizCustomerSet.BizCustomerFeeDetail.Add(new BizCustomerFeeDetailModel() { CustomerCode = custCode, RowState = RowState.Insert, ChannelGroupType = ChannelGroupType.Market, BankFeeType = BankFeeType.TotalFee, Fee = accftt.ACTFEEMART.ToDecimal(), IntroPercent = accftt.ACTPERCENT.ToDecimal(), }); } //郵局-每筆總手續費 if (!accftt.ACTFEEPOST.IsNullOrEmpty()) { bizCustomerSet.BizCustomerFeeDetail.Add(new BizCustomerFeeDetailModel() { CustomerCode = custCode, RowState = RowState.Insert, ChannelGroupType = ChannelGroupType.Post, BankFeeType = BankFeeType.TotalFee, Fee = accftt.ACTFEEPOST.ToDecimal(), IntroPercent = accftt.POSTPERCENT.ToDecimal(), }); } //農金-清算手續費 if (!accftt.AGRIFEE.IsNullOrEmpty()) { bizCustomerSet.BizCustomerFeeDetail.Add(new BizCustomerFeeDetailModel() { CustomerCode = custCode, RowState = RowState.Insert, ChannelGroupType = ChannelGroupType.Market, BankFeeType = BankFeeType.ClearFee_NextMonth, Fee = accftt.AGRIFEE.ToDecimal(), IntroPercent = 0, }); } return(bizCustomerSet); }
/// <summary> /// 檢查資料 /// </summary> /// <param name="message"></param> /// <param name="set"></param> public static void CheckData(SysMessageLog message, BizCustomerSet set) { CheckVirtualAccountLength(message, set.BizCustomer); CheckBizCustType(message, set); CheckIntroduceType(message, set.BizCustomerFeeDetail); }