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;
            }
        }
Beispiel #2
0
        /// <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;
                }
            }
        }