Example #1
0
        private static void ExprotContract()
        {
            SqlConnection conn   = new SqlConnection("Server=.;Initial Catalog=E_Commerce_DB;User ID=sa;Password=dq123456");
            StringBuilder sqlstr = new StringBuilder();

            sqlstr.Append(@"select * from Test003 ");
            conn.Open();
            SqlCommand    comm = new SqlCommand(sqlstr.ToString(), conn);
            SqlDataReader sdr  = comm.ExecuteReader();

            contractEntity        list     = new contractEntity();
            List <contractEntity> conlists = new List <contractEntity>();

            while (sdr.Read())
            {
                list = new contractEntity
                {
                    projectname            = sdr[0].ToString(),
                    ecommercename          = sdr[1].ToString(),
                    ecommercegroupname     = sdr[2].ToString(),
                    platfromrate           = Convert.ToDecimal(sdr[3]),
                    contractname           = sdr[4].ToString(),
                    ControllerAmount       = Convert.ToDecimal(sdr[5]),
                    FlowAmount             = Convert.ToDecimal(sdr[6]),
                    ActualControllerAmount = Convert.ToDecimal(sdr[7])
                };
                conlists.Add(list);
                if (!sdr.HasRows)
                {
                    list = new contractEntity
                    {
                        projectname = "",
                    };
                    conlists.Add(list);
                }
            }
            sdr.Close();
            conn.Close();

            Base_ProjectInfoBLL                   bpbbll         = new Base_ProjectInfoBLL();
            EcommerceBLL                          ecombll        = new EcommerceBLL();
            EcommerceGroupBLL                     ecomgroupbll   = new EcommerceGroupBLL();
            List <EcommerceGroupEntity>           ecomgrouplists = new List <EcommerceGroupEntity>();
            List <EcommerceEntity>                ecomlists      = new List <EcommerceEntity>();
            List <EcommerceProjectRelationEntity> ecomprorelists = new List <EcommerceProjectRelationEntity>();
            int count = 0;

            foreach (var item in conlists)
            {
                count++;
                var data = bpbbll.GetList("").ToList().Where(t => t.ProjecName == item.projectname).ToList();
                if (data.Count == 0)
                {
                    Console.WriteLine("找不到对应的项目数据'" + item.projectname + "'");
                    Console.ReadKey();
                    return;
                }
                EcommerceProjectRelationEntity ecom = new EcommerceProjectRelationEntity();
                ecom.EcommerceProjectRelationID = Guid.NewGuid().ToString();
                var ecomgroupdata = ecomgroupbll.GetList("").Where(t => t.EcommerceGroupName == item.ecommercegroupname).ToList();
                if (ecomgroupdata.Count == 0)
                {
                    EcommerceGroupEntity ecomgroupentity = new EcommerceGroupEntity();
                    ecomgroupentity.EcommerceGroupID   = Guid.NewGuid().ToString();
                    ecomgroupentity.EcommerceGroupName = item.ecommercegroupname;
                    ecomgroupentity.DeleteMark         = 0;
                    var t2 = new SqlDatabase("BaseDb").Connection.Insertable(ecomgroupentity).ExecuteCommand();
                    //if (!ecomgrouplists.Any(t => t.EcommerceGroupName == ecomgroupentity.EcommerceGroupName))
                    //{
                    //    ecomgrouplists.Add(ecomgroupentity);
                    //}
                    EcommerceEntity ecomentity = new EcommerceEntity();
                    ecomentity.EcommerceName      = item.ecommercename;
                    ecomentity.EcommerceID        = Guid.NewGuid().ToString();
                    ecomentity.EcommerceGroupID   = ecomgroupentity.EcommerceGroupID;
                    ecomentity.EcommerceCode      = count.ToString();
                    ecomentity.EcommerceGroupName = ecomgroupentity.EcommerceGroupName;
                    ecomentity.DeleteMark         = 0;
                    ecomentity.EcommerceType      = 0;
                    ecomentity.PlatformRate       = item.platfromrate;
                    ecomentity.CooperateStartTime = Convert.ToDateTime("2018-01-01");
                    ecomentity.CooperateEndTime   = Convert.ToDateTime("2018-06-30");
                    var t3 = new SqlDatabase("BaseDb").Connection.Insertable(ecomentity).ExecuteCommand();
                    //if (!ecomlists.Any(t => t.EcommerceName == ecomentity.EcommerceName))
                    //{
                    //    ecomlists.Add(ecomentity);
                    //}
                    ecom.EcommerceGroupID   = ecomgroupentity.EcommerceGroupID;
                    ecom.EcommerceGroupName = ecomgroupentity.EcommerceGroupName;
                    ecom.EcommerceID        = ecomentity.EcommerceID;
                    ecom.EcommerceName      = ecomentity.EcommerceName;
                    ecom.EcommerceCode      = ecomentity.EcommerceCode;
                    ecom.PartyB             = ecomentity.EcommerceName;
                }
                else
                {
                    ecom.EcommerceGroupID   = ecomgroupdata[0].EcommerceGroupID;
                    ecom.EcommerceGroupName = ecomgroupdata[0].EcommerceGroupName;
                    var ecomdata = ecombll.GetList("").Where(t => t.EcommerceName == item.ecommercename).ToList();
                    if (ecomdata.Count == 0)
                    {
                        EcommerceEntity ecomentity = new EcommerceEntity();
                        ecomentity.EcommerceName      = item.ecommercename;
                        ecomentity.EcommerceID        = Guid.NewGuid().ToString();
                        ecomentity.EcommerceCode      = count.ToString();
                        ecomentity.EcommerceGroupID   = ecomgroupdata[0].EcommerceGroupID;
                        ecomentity.EcommerceGroupName = ecomgroupdata[0].EcommerceGroupName;
                        ecomentity.PlatformRate       = item.platfromrate;
                        ecomentity.DeleteMark         = 0;
                        ecomentity.EcommerceType      = 0;
                        ecomentity.CooperateStartTime = Convert.ToDateTime("2018-01-01");
                        ecomentity.CooperateEndTime   = Convert.ToDateTime("2018-06-30");
                        var t3 = new SqlDatabase("BaseDb").Connection.Insertable(ecomentity).ExecuteCommand();
                        //if (!ecomlists.Any(t => t.EcommerceName == ecomentity.EcommerceName))
                        //{
                        //    ecomlists.Add(ecomentity);
                        //}
                        ecom.EcommerceGroupID    = ecomentity.EcommerceGroupID;
                        ecom.EcommerceGroupName  = ecomentity.EcommerceGroupName;
                        ecom.EcommerceID         = ecomentity.EcommerceID;
                        ecom.EcommerceName       = ecomentity.EcommerceName;
                        ecomentity.EcommerceCode = ecomentity.EcommerceCode;
                        ecom.PartyB = ecomentity.EcommerceName;
                    }
                    else
                    {
                        ecom.EcommerceID   = ecomdata[0].EcommerceID;
                        ecom.EcommerceName = ecomdata[0].EcommerceName;
                        ecom.EcommerceCode = ecomdata[0].EcommerceCode;
                        ecom.PartyB        = ecomdata[0].EcommerceName;
                    }
                }
                ecom.PlatformRate             = item.platfromrate;
                ecom.ContractName             = item.contractname;
                ecom.EcommerceType            = 0;
                ecom.EcommerceTypeName        = EnumHelper.ToDescription((EcommerceTypeEnum)0);
                ecom.Agent                    = "金涛";
                ecom.CooperateStartTime       = Convert.ToDateTime("2018-01-01");
                ecom.CooperateEndTime         = Convert.ToDateTime("2018-06-30");
                ecom.ForceContractAmount      = 100000;
                ecom.DeleteMark               = 0;
                ecom.CityCode                 = data[0].CityCode;
                ecom.CityID                   = data[0].CityID;
                ecom.CityName                 = data[0].CityName;
                ecom.ProjectID                = data[0].ProjectID;
                ecom.ProjectCode              = data[0].ProjectCode;
                ecom.ProjecName               = item.projectname;
                ecom.CompanyId                = data[0].CompanyCode;
                ecom.CompanyCode              = data[0].CompanyCode;
                ecom.CompanyName              = data[0].CompanyName;
                ecom.ProjectType              = 0;
                ecom.ApprovalState            = 4;
                ecom.FlowNopayTotalAmount     = 0;
                ecom.ContractNature           = 0;
                ecom.IsStandard               = 1;
                ecom.PartyA                   = "阳光城集团股份有限公司";
                ecom.BiddingMethod            = 0;
                ecom.IsStamp                  = 1;
                ecom.ContractTypeName         = "主合同";
                ecom.CreateDate               = Convert.ToDateTime("2018-06-30");
                ecom.ControlTotalAmount       = item.ControllerAmount * 0;
                ecom.FlowNopayTotalAmount     = item.FlowAmount * 10000;
                ecom.ActualControlTotalAmount = item.ActualControllerAmount * 10000;
                ecom.IsTrunk                  = 1;
                if (!ecomprorelists.Any(t => t.EcommerceID == ecom.EcommerceID && t.ProjectID == ecom.ProjectID))
                {
                    ecomprorelists.Add(ecom);
                }
            }
            var t1 = new SqlDatabase("BaseDb").Connection.Insertable(ecomprorelists).ExecuteCommand();

            //var t2 = new SqlDatabase("BaseDb").Connection.Insertable(ecomgrouplists).ExecuteCommand();
            //var t3 = new SqlDatabase("BaseDb").Connection.Insertable(ecomlists).ExecuteCommand();
            Console.ReadKey();
        }
Example #2
0
        public void PostPaymentuse()
        {
            SqlConnection conn = new SqlConnection("Server=.;Initial Catalog=mytest;User ID=sa;Password=123456;Pooling=true;Max Pool Size=1024;Min Pool Size=0;");

            StringBuilder sqlstr = new StringBuilder();

            sqlstr.Append(@"select * from daorushuju");
            conn.Open();
            SqlCommand    comm = new SqlCommand(sqlstr.ToString(), conn);
            SqlDataReader sdr  = comm.ExecuteReader();

            Pay_InfoEntity        payinfo      = new Pay_InfoEntity();
            List <Pay_InfoEntity> payinfolists = new List <Pay_InfoEntity>();

            while (sdr.Read())
            {
                payinfo = new Pay_InfoEntity
                {
                    Project_Name = sdr[2].ToString().Trim(),
                    Electricity_Supplier_Name = sdr[3].ToString().Trim(),
                    Pay_Money   = Convert.ToDecimal(sdr[6]),
                    Pay_Info_Id = sdr[10].ToString()
                };
                payinfolists.Add(payinfo);
                if (!sdr.HasRows)
                {
                    payinfo = new Pay_InfoEntity
                    {
                        Project_Name = "",
                    };
                    payinfolists.Add(payinfo);
                }
            }
            sdr.Close();
            conn.Close();

            string                      datetime       = DateTime.Now.ToString("yyyyMMdd");
            string                      paycode        = "History" + datetime + "A00";
            string                      i              = "1";
            string                      hetong         = "HT-" + datetime + "-00";
            EcommerceBLL                ecombll        = new EcommerceBLL();
            Base_ProjectInfoBLL         bpbbll         = new Base_ProjectInfoBLL();
            EcommerceProjectRelationBLL ecomprorelabll = new EcommerceProjectRelationBLL();
            bool isexprot = true;

            foreach (var item in payinfolists)
            {
                var projectdata = bpbbll.GetList("").ToList().Where(t => t.ProjecName == item.Project_Name).ToList();
                var ecomdata    = ecombll.GetList("").Where(t => t.EcommerceName == item.Electricity_Supplier_Name).ToList();
                if (ecomdata.Count == 0)
                {
                    isexprot = false;
                    string msg = string.Format("不存在该电商公司:{0}", item.Electricity_Supplier_Name);
                    Info(msg);
                    continue;
                }
                bool isexist = ecomprorelabll.GetProjectAndEcom().Any(t => t.ProjecName == item.Project_Name &&
                                                                      t.EcommerceName == item.Electricity_Supplier_Name);
                if (!isexist)
                {
                    isexprot = false;
                    string msg = string.Format("该电商公司(  {0}  )和项目(  {1}  )不存在", item.Electricity_Supplier_Name, item.Project_Name);
                    Error(msg);
                    continue;
                }
                InputPaymentuse abc = new InputPaymentuse();
                if (i.Length == 1)
                {
                    i = "0" + i;
                }
                abc.pay_info_id                = item.Pay_Info_Id;
                abc.pay_info_code              = paycode + i;
                abc.electricity_supplier_name  = item.Electricity_Supplier_Name;
                abc.electricity_supplier_code  = ecomdata[0].EcommerceCode;
                abc.electricity_supplier_id    = ecomdata[0].EcommerceID;
                abc.electricity_supplier_ad_id = ecomdata[0].EcommerceGroupID;
                abc.electricity_supplier_ad    = ecomdata[0].EcommerceGroupName;
                abc.project_code               = projectdata[0].ProjectCode;
                abc.project_id       = projectdata[0].ProjectID;
                abc.project_name     = item.Project_Name;
                abc.pay_info_type    = "EC";
                abc.contract_code    = hetong + i;
                abc.contract_name    = item.Project_Name + "历史合同数据";
                abc.pay_money        = Convert.ToDecimal(item.Pay_Money);
                abc.pay_createtime   = Convert.ToDateTime("2018/08/01");
                abc.pay_completetime = Convert.ToDateTime("2018/08/31");
                abc.pay_reason       = "导入历史数据";
                abc.approval_status  = "SUBMITED";
                abc.url        = "https://fssc.yango.com.cn/jiebao-plus/#/app/smart_expense/form/EC/306991952048422912/detail";
                abc.login_name = "金涛";
                abc.login_code = "金涛";
                i = (Convert.ToInt32(i) + 1).ToString();
                string param         = abc.ToJson();
                string a             = "";
                string paydatadetail = abc.ToJson();
                // data(paydatadetail);
            }
            if (!isexprot)
            {
                return;
            }
            foreach (var item in payinfolists)
            {
                var projectdata = bpbbll.GetList("").ToList().Where(t => t.ProjecName == item.Project_Name).ToList();
                var ecomdata    = ecombll.GetList("").Where(t => t.EcommerceName == item.Electricity_Supplier_Name).ToList();
                if (ecomdata.Count == 0)
                {
                    string msg = string.Format("不存在该电商公司:{0}", item.Electricity_Supplier_Name);
                    Error(msg);
                }
                InputPaymentuse abc = new InputPaymentuse();
                if (i.Length == 1)
                {
                    i = "0" + i;
                }
                abc.pay_info_id                = item.Pay_Info_Id;
                abc.pay_info_code              = paycode + i;
                abc.electricity_supplier_name  = item.Electricity_Supplier_Name;
                abc.electricity_supplier_code  = ecomdata[0].EcommerceCode;
                abc.electricity_supplier_id    = ecomdata[0].EcommerceID;
                abc.electricity_supplier_ad_id = ecomdata[0].EcommerceGroupID;
                abc.electricity_supplier_ad    = ecomdata[0].EcommerceGroupName;
                abc.project_code               = projectdata[0].ProjectCode;
                abc.project_id       = projectdata[0].ProjectID;
                abc.project_name     = item.Project_Name;
                abc.pay_info_type    = "EC";
                abc.contract_code    = hetong + i;
                abc.contract_name    = item.Project_Name + "历史合同数据";
                abc.pay_money        = Convert.ToDecimal(item.Pay_Money);
                abc.pay_createtime   = Convert.ToDateTime("2018/08/01");
                abc.pay_completetime = Convert.ToDateTime("2018/08/31");
                abc.pay_reason       = "导入历史数据";
                abc.approval_status  = "AUDITED";
                abc.url        = "https://fssc.yango.com.cn/jiebao-plus/#/app/smart_expense/form/EC/306991952048422912/detail";
                abc.login_name = "金涛";
                abc.login_code = "金涛";
                i = (Convert.ToInt32(i) + 1).ToString();
                string param = abc.ToJson();
                string a     = "";

                string res = HttpMethods.PostResponse("http://172.19.10.206:8090/api/money/paymentuse", param, out a);
            }
        }