Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
        public async Task <Resp <bool> > PostPaymentuse(InputPaymentuse inputModel)
        {
            string errMsg   = string.Empty;
            int    reqState = 1;
            bool   result   = false;

            #region 入参校验
            //验证实体对象属性信息

            #endregion
            try
            {
                var errorResult = GetError();
                if (!string.IsNullOrWhiteSpace(errorResult))
                {
                    errMsg   = errorResult;
                    reqState = 0;
                    return(Resp.BusinessError(errMsg, result));
                }
                if (inputModel.pay_money <= 0)
                {
                    errMsg   = "金额异常!";
                    reqState = 0;
                    return(Resp.BusinessError(errMsg, result));
                }
                await Task.Run(() =>
                {
                    var _approval = 0;
                    switch (inputModel.approval_status)
                    {
                    case "AUDITED":     // 已审批 消费金额
                        _approval = (int)ApproveStatus.approved;
                        break;

                    case "DRAFT":     // DRAFT 草稿 释放
                        _approval = (int)ApproveStatus.draft;
                        break;

                    case "SUBMITED":     //SUBMITED 待审批 占用(注意金额的变化,变化是需要修改)
                        _approval = (int)ApproveStatus.in_approval;
                        break;

                    case "DISABLED":    // DISABLED 已作废 释放
                        _approval = (int)ApproveStatus.deleted;
                        break;

                    default:
                        break;
                    }
                    var model = new Pay_InfoEntity()
                    {
                        Approval_Status           = _approval.ToString(),
                        Contract_Code             = inputModel.contract_code,
                        Contract_Name             = inputModel.contract_name,
                        ContractMoney             = inputModel.pay_money,
                        CreateUserName            = inputModel.login_name,
                        EcommerceGroupID          = inputModel.electricity_supplier_ad_id,
                        EcommerceID               = inputModel.electricity_supplier_id,
                        Electricity_Supplier_Code = inputModel.electricity_supplier_code,
                        Electricity_Supplier_Name = inputModel.electricity_supplier_name,
                        EcommerceGroupName        = inputModel.electricity_supplier_ad,
                        Login_Code       = inputModel.login_code,
                        Login_Name       = inputModel.login_name,
                        Pay_Completetime = inputModel.pay_completetime,
                        Pay_Createtime   = inputModel.pay_createtime,
                        Pay_Info_Code    = inputModel.pay_info_code,
                        Pay_Info_Id      = inputModel.pay_info_id,
                        Pay_Info_Type    = inputModel.pay_info_type,
                        Pay_Money        = inputModel.pay_money,
                        Pay_Reason       = inputModel.pay_reason,
                        Project_Code     = inputModel.project_code,
                        Project_Id       = inputModel.project_id,
                        Project_Name     = inputModel.project_name,
                        Url = inputModel.url,
                    };
                    payInfoBll.Paymentuse(inputModel.pay_info_id, model);
                });

                result = true;
                return(Resp.Success(result));
            }
            catch (Exception ex)
            {
                errMsg   = ex.Message;
                reqState = 0;
                return(Resp.BusinessError(errMsg, result));
            }
            finally
            {
                string ResponseContent = reqState == 0 ? Resp.BusinessError <bool>(errMsg, result).ToJson()
               : Resp.Success(result).ToJson();
                LogBLL.WriteLogInterface(inputModel.ToJson(),
                                         ResponseContent, "资金占用情况",
                                         reqState, "共享平台", "电商资金", errMsg);
            }
        }