public Result ChangeReviewState(List <int> ids, int state)
        {
            db = new Db();

            try
            {
                List <Generation_buckle> buckle_list = db.Generation_buckle.Where(t => ids.Contains(t.id)).ToList();
                buckle_list.ForEach(t => t.review_state = state);

                db.SaveChanges();

                if (state == 4) //省级推送
                {
                    if (buckle_list.Count > 0)
                    {
                        //using (var buckle_scope = new TransactionScope())
                        {
                            decimal sum_amount = Convert.ToDecimal(buckle_list.Sum(t => t.salesman_cash_deposit));

                            MioBatch mio_batch = new MioBatch();                                              //写入本数据库中的 收付批次表
                            mio_batch.batch_id      = DateTime.Now.Ticks.ToString();                          //批次号
                            mio_batch.record_count  = buckle_list.Count;                                      //批次中包含的收付笔数
                            mio_batch.sum_amount    = sum_amount;                                             //批次总金额
                            mio_batch.reviewer_code = HttpContext.Current.Request.Cookies["user_code"].Value; //审核人工号
                            mio_batch.review_date   = DateTime.Now;                                           //审核日期
                            mio_batch.push_date     = DateTime.Now;                                           //推送日期
                            mio_batch.mio_type      = "I";                                                    //收付类型 I收、O付

                            db.MioBatch.Add(mio_batch);

                            List <MioList> mio_list = new List <MioList>(); //写入本数据库中的 收付明细表
                            buckle_list.ForEach(
                                t =>
                                mio_list.Add(new MioList()
                            {
                                batch_id          = mio_batch.batch_id,
                                generation_id     = t.id,
                                mio_type          = "代扣",
                                bank_account_no   = t.salesman_bank_account_number,
                                bank_account_name = t.salesman_bank_account_name,
                                cash_deposit      = t.salesman_cash_deposit,
                                status            = -1,
                                result            = "代扣处理中..."
                            }));

                            db.MioList.AddRange(mio_list);

                            //using (var gives_scope = new TransactionScope())
                            {
                                DbInterface db_context = new DbInterface();

                                INTERFACE_MIO_BATCH_BZJ batch = new INTERFACE_MIO_BATCH_BZJ(); //写入保证金收付接口表——批次表
                                batch.MioType      = "I";                                      //收付类型 I收、O付
                                batch.DataCnt      = buckle_list.Count;                        //批次中包含的收付笔数
                                batch.SumAmnt      = sum_amount;                               //批次总金额
                                batch.GenerateTime = DateTime.Now;                             //批次生成的时间
                                batch.GenerateBy   = HttpContext.Current.Request.Cookies["user_code"].Value;
                                //产生数据人员,八位ERP工号
                                batch.FromBatchNo = mio_batch.batch_id; //外部系统批次号
                                batch.BatchStatus = 0;                  //批次状态(默认为0)

                                batch.FromSys = "UnKnow";               //外部系统编号

                                db_context.INTERFACE_MIO_BATCH_BZJ.Add(batch);
                                db_context.SaveChanges();

                                INTERFACE_MIO_LIST_BZJ mio = null;
                                buckle_list.ForEach(t =>
                                {
                                    mio                    = new INTERFACE_MIO_LIST_BZJ();
                                    mio.ClicBranch         = t.agency_code;                  //待收付数据的机构(与商户号相关)
                                    mio.BatchId            = batch.BatchId;                  //接口批次表生成的id
                                    mio.ApplTime           = DateTime.Now;                   //审核时间
                                    mio.ProcStatus         = "0";                            //数据检查结果,0-新数据待检查,1检验通过,2审核通过
                                    mio.AccBookOrCard      = "C";                            //帐号类型(C银行卡,B存折)
                                    mio.AccPersonOrCompany = "P";                            //P私人,C公司。不填时,默认为私人
                                    mio.BankAccName        = t.salesman_bank_account_name;   //银行户名
                                    mio.BankAcc            = t.salesman_bank_account_number; //银行账号
                                    mio.MioAmount          = t.salesman_cash_deposit.Value;  //交易金额
                                    mio.FromSys            = "UnKnow";                       //外部系统编号
                                    mio.FromBatchNo        = batch.FromBatchNo;              //外部系统批次号
                                    mio.MioStatus          = -1;                             //收付结果。成功、余额不足、户名错、账户冻结等,需字典表
                                    mio.AccCurrencyType    = "CNY";                          //人民币:CNY, 港元:HKD,美元:USD。不填时,默认为人民币。

                                    mio.FromUniqLine = "UnKnow";                             //外部系统对于本条数据的唯一编码
                                    mio.BankCode     = t.salesman_bank_name;                 //中国人寿编码的银行代码,需转换为银联代码

                                    db_context.INTERFACE_MIO_LIST_BZJ.Add(mio);
                                });

                                db_context.SaveChanges();
                                //gives_scope.Complete();
                            }

                            db.SaveChanges();
                            //buckle_scope.Complete();

                            QuartzManager <QueryBuckleInfo> .AddJob(mio_batch.batch_id, "0 1/1 * * * ?");

                            //1分钟之后执行第一次(对应“1/1”第一个1),然后每隔1分钟执行一次(对应“1/1”第二个1)
                        }
                    }
                }

                return(new Result(ResultType.success));
            }
            catch (DbEntityValidationException ex)
            {
                return(new Result(ResultType.error, new Message(ex).ErrorDetails));
            }
        }
예제 #2
0
        public void Execute(IJobExecutionContext context)
        {
            db_interface = db_interface ?? new DbInterface();
            batch_id     = batch_id ?? context.JobDetail.Key.Name;

            INTERFACE_MIO_BATCH_BZJ batch_interface =
                db_interface.INTERFACE_MIO_BATCH_BZJ.SingleOrDefault(t => t.FromBatchNo == batch_id);

            if (batch_interface != null && batch_interface.BatchStatus == 5)
            {
                try
                {
                    db = new Db();

                    var batch = db.MioBatch.SingleOrDefault(t => t.batch_id == batch_id);
                    batch.done_date   = DateTime.Now;
                    batch.push_result = batch_interface.Remark;
                    db.Update(batch);

                    var batch_interface_list =
                        db_interface.INTERFACE_MIO_LIST_BZJ.Where(t => t.FromBatchNo == batch_id).ToList(); //获取清单表

                    Generation_gives gives = null;

                    var batch_list = db.MioList.Where(t => t.batch_id == batch_id).ToList();
                    batch_list.ForEach(t =>
                    {
                        var batch_detail =
                            batch_interface_list.SingleOrDefault(
                                s =>
                                s.FromBatchNo == batch_id && s.BankAcc == t.bank_account_no &&
                                s.BankAccName == t.bank_account_name);
                        t.status = batch_detail.MioStatus;
                        t.result = batch_detail.ErrMsg; //将清单表信息复制过来
                        db.Update(t);

                        gives = db.Generation_gives.SingleOrDefault(b => b.id == t.generation_id);
                        if (gives != null)
                        {
                            if (t.status == 0) //0表示处理成功
                            {
                                gives.review_state = 6;
                            }
                            else
                            {
                                gives.review_state = -6; //失败退回到提交状态
                            }
                            gives.process_result = batch_detail.ErrMsg;
                            gives.finish_time    = batch_detail.FinishTime;
                            db.Update(gives);
                        }
                    });

                    db.SaveChanges();
                }
                finally
                {
                    QuartzManager <QueryGivesInfo> .RemoveJob(batch_id);
                }
            }
        }
예제 #3
0
        public void Execute(IJobExecutionContext context)
        {
            db_interface = db_interface ?? new DbInterface();
            batch_id     = batch_id ?? context.JobDetail.Key.Name;

            INTERFACE_MIO_BATCH_BZJ batch_interface =
                db_interface.INTERFACE_MIO_BATCH_BZJ.SingleOrDefault(t => t.FromBatchNo == batch_id);

            if (batch_interface != null && batch_interface.BatchStatus == 5) //处理完成
            {
                try
                {
                    db = new Db();

                    var batch = db.MioBatch.SingleOrDefault(t => t.batch_id == batch_id);
                    batch.done_date   = DateTime.Now;
                    batch.push_result = batch_interface.Remark;
                    db.Update(batch);

                    var batch_interface_list =
                        db_interface.INTERFACE_MIO_LIST_BZJ.Where(t => t.FromBatchNo == batch_id).ToList(); //获取清单表

                    Generation_buckle buckle = null;

                    var           batch_list = db.MioList.Where(t => t.batch_id == batch_id).ToList();
                    List <string> phones     = new List <string>();
                    batch_list.ForEach(t =>
                    {
                        var batch_detail =
                            batch_interface_list.SingleOrDefault(
                                s =>
                                s.FromBatchNo == batch_id && s.BankAcc == t.bank_account_no &&
                                s.BankAccName == t.bank_account_name);

                        t.status = batch_detail.MioStatus;
                        t.result = batch_detail.ErrMsg; //将清单表信息复制过来
                        db.Update(t);

                        buckle = db.Generation_buckle.SingleOrDefault(b => b.id == t.generation_id);
                        if (buckle != null)
                        {
                            if (t.status == 0) //0表示处理成功
                            {
                                buckle.review_state = 5;

                                int count      = 0;
                                int cur_num    = 1;
                                string max_num = db.Generation_buckle.Max(g => g.gather_serial_num);
                                /*--------------------生成流水号--------------------*/
                                if (max_num != null)
                                {
                                    cur_num = int.Parse(max_num.Substring(12));
                                    cur_num++;
                                }
                                max_num = cur_num.ToString();
                                count   = 8 - cur_num.ToString().Length;
                                for (int i = 0; i < count; i++)
                                {
                                    max_num = "0" + max_num;
                                }
                                buckle.gather_serial_num = DateTime.Now.Year + buckle.agency_code + "88" + max_num;
                                /*--------------------生成虚拟销售人员代码--------------------*/
                                cur_num = 1;
                                max_num = db.Generation_buckle.Max(g => g.salesman_code);
                                if (max_num != null)
                                {
                                    cur_num = int.Parse(max_num.Substring(6));
                                    cur_num++;
                                }
                                max_num = cur_num.ToString();
                                count   = 8 - cur_num.ToString().Length;
                                for (int i = 0; i < count; i++)
                                {
                                    max_num = "0" + max_num;
                                }
                                buckle.salesman_code = buckle.agency_code + max_num;

                                phones.Add(buckle.salesman_phone);
                            }
                            else
                            {
                                buckle.review_state = -5; //失败退回到市级未提交状态
                            }
                            buckle.process_result = batch_detail.ErrMsg;
                            buckle.finish_time    = batch_detail.FinishTime;
                            db.Update(buckle);
                        }
                    });

                    db.SaveChanges();

                    var client = new WebClient();
                    client.Encoding = Encoding.UTF8;
                    phones.ForEach(phone =>
                    {
                        client.DownloadString(
                            "http://10.20.147.103:8080/api/json/reply/sendmsg?username=43010271000014&password=170046&systemid=0&mobile=" +
                            phone + "&content=银行代扣成功&dept=信息技术部&clerk=李轩");
                    });
                }
                finally
                {
                    QuartzManager <QueryBuckleInfo> .RemoveJob(batch_id);
                }
            }
        }
        private void Push(List <Generation_gives> list)
        {
            if (list.Count > 0)
            {
                //using (var scope = new TransactionScope())
                {
                    decimal sum_amount = Convert.ToDecimal(list.Sum(t => t.salesman_cash_deposit));

                    MioBatch mio_batch = new MioBatch();                                              //写入本数据库中的 收付批次表
                    mio_batch.batch_id      = DateTime.Now.Ticks.ToString();                          //批次号
                    mio_batch.record_count  = list.Count;                                             //批次中包含的收付笔数
                    mio_batch.sum_amount    = sum_amount;                                             //批次总金额
                    mio_batch.reviewer_code = HttpContext.Current.Request.Cookies["user_code"].Value; //审核人工号
                    mio_batch.review_date   = DateTime.Now;                                           //审核日期
                    mio_batch.push_date     = DateTime.Now;                                           //推送日期
                    mio_batch.mio_type      = "O";                                                    //收付类型 I收、O付

                    db.MioBatch.Add(mio_batch);

                    List <MioList> mio_list = new List <MioList>(); //写入本数据库中的 收付明细表
                    list.ForEach(
                        t =>
                        mio_list.Add(new MioList()
                    {
                        batch_id          = mio_batch.batch_id,
                        generation_id     = t.id,
                        mio_type          = "代付",
                        bank_account_no   = t.salesman_bank_account_number,
                        bank_account_name = t.salesman_bank_account_name,
                        cash_deposit      = t.salesman_cash_deposit,
                        status            = -1,
                        result            = "正在处理中"
                    }));

                    db.MioList.AddRange(mio_list);

                    DbInterface db_context = new DbInterface();

                    INTERFACE_MIO_BATCH_BZJ batch = new INTERFACE_MIO_BATCH_BZJ();               //写入保证金收付接口表——批次表
                    batch.MioType      = "O";                                                    //收付类型 I收、O付
                    batch.DataCnt      = list.Count;                                             //批次中包含的收付笔数
                    batch.SumAmnt      = sum_amount;                                             //批次总金额
                    batch.GenerateTime = DateTime.Now;                                           //批次生成的时间
                    batch.GenerateBy   = HttpContext.Current.Request.Cookies["user_code"].Value; //产生数据人员,八位ERP工号
                    batch.FromBatchNo  = mio_batch.batch_id;                                     //外部系统批次号
                    batch.BatchStatus  = 0;                                                      //批次状态(默认为0)

                    batch.FromSys = "UnKnow";                                                    //外部系统编号

                    db_context.INTERFACE_MIO_BATCH_BZJ.Add(batch);
                    db_context.SaveChanges();

                    INTERFACE_MIO_LIST_BZJ mio = null;
                    list.ForEach(t =>
                    {
                        mio                    = new INTERFACE_MIO_LIST_BZJ();
                        mio.ClicBranch         = t.agency_code;                  //待收付数据的机构(与商户号相关)
                        mio.BatchId            = batch.BatchId;                  //接口批次表生成的id
                        mio.ApplTime           = DateTime.Now;                   //审核时间
                        mio.ProcStatus         = "0";                            //数据检查结果,0-新数据待检查,1检验通过,2审核通过
                        mio.AccBookOrCard      = "C";                            //帐号类型(C银行卡,B存折)
                        mio.AccPersonOrCompany = "P";                            //P私人,C公司。不填时,默认为私人
                        mio.BankAccName        = t.salesman_bank_account_name;   //银行户名
                        mio.BankAcc            = t.salesman_bank_account_number; //银行账号
                        mio.MioAmount          = t.salesman_cash_deposit.Value;  //交易金额
                        mio.FromSys            = "UnKnow";                       //外部系统编号
                        mio.FromBatchNo        = batch.FromBatchNo;              //外部系统批次号
                        mio.MioStatus          = -1;                             //收付结果。成功、余额不足、户名错、账户冻结等,需字典表
                        mio.AccCurrencyType    = "CNY";                          //人民币:CNY, 港元:HKD,美元:USD。不填时,默认为人民币。

                        mio.FromUniqLine = "UnKnow";                             //外部系统对于本条数据的唯一编码
                        mio.BankCode     = t.salesman_bank_name;                 //中国人寿编码的银行代码,需转换为银联代码

                        db_context.INTERFACE_MIO_LIST_BZJ.Add(mio);
                    });

                    db_context.SaveChanges();
                    db.SaveChanges();

                    //scope.Complete();

                    QuartzManager <QueryGivesInfo> .AddJob(mio_batch.batch_id, "0 1/1 * * * ?");

                    //1分钟之后执行第一次(对应“1/1”第一个1),然后每隔1分钟执行一次(对应“1/1”第二个1)
                }
            }
        }