예제 #1
0
        public ResultModel Update(UserModel user, NFMT.Operate.Model.Apply apply, NFMT.DoPrice.Model.PricingApply pricingApply, List<NFMT.DoPrice.Model.PricingApplyDetail> pricingApplyDetails)
        {
            ResultModel result = new ResultModel();
            NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
            DAL.PricingApplyDAL pricingApplyDAL = new PricingApplyDAL();
            DAL.PricingApplyDetailDAL pricingApplyDetailDAL = new PricingApplyDetailDAL();
            NFMT.Contract.DAL.ContractSubDAL subDAL = new Contract.DAL.ContractSubDAL();
            NFMT.Contract.DAL.ContractDAL contractDAL = new Contract.DAL.ContractDAL();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = applyDAL.Get(user, apply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;
                    NFMT.Operate.Model.Apply getApply = result.ReturnValue as NFMT.Operate.Model.Apply;
                    if (getApply == null || getApply.ApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取申请错误";
                        return result;
                    }

                    NFMT.User.Model.Department dept = NFMT.User.UserProvider.Departments.FirstOrDefault(temp => temp.DeptId == apply.ApplyDept);
                    if (dept == null || dept.DeptId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "申请部门不存在";
                        return result;
                    }

                    getApply.EmpId = user.EmpId;
                    getApply.ApplyTime = DateTime.Now;
                    getApply.ApplyDept = apply.ApplyDept;
                    getApply.ApplyCorp = apply.ApplyCorp;
                    getApply.ApplyDesc = apply.ApplyDesc;
                    result = applyDAL.Update(user, getApply);
                    if (result.ResultStatus != 0)
                        return result;

                    result = pricingApplyDAL.Get(user, pricingApply.PricingApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.DoPrice.Model.PricingApply getPricingApply = result.ReturnValue as NFMT.DoPrice.Model.PricingApply;
                    if (getPricingApply == null || getPricingApply.PricingApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取点价申请错误";
                        return result;
                    }

                    getPricingApply.StartTime = pricingApply.StartTime;
                    getPricingApply.EndTime = pricingApply.EndTime;
                    getPricingApply.MinPrice = pricingApply.MinPrice;
                    getPricingApply.MaxPrice = pricingApply.MaxPrice;
                    getPricingApply.CurrencyId = pricingApply.CurrencyId;
                    getPricingApply.PricingCorpId = pricingApply.PricingCorpId;
                    getPricingApply.PricingWeight = pricingApply.PricingWeight;
                    getPricingApply.MUId = pricingApply.MUId;
                    getPricingApply.AssertId = pricingApply.AssertId;
                    getPricingApply.PricingPersoinId = pricingApply.PricingPersoinId;

                    //验证子合约
                    result = subDAL.Get(user, pricingApply.SubContractId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Contract.Model.ContractSub sub = result.ReturnValue as NFMT.Contract.Model.ContractSub;
                    if (sub == null || sub.SubId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "子合约不存在";
                        return result;
                    }

                    if (sub.SubStatus != StatusEnum.已生效)
                    {
                        result.ResultStatus = -1;
                        result.Message = "子合约状态非已生效,不能进行点价申请";
                        return result;
                    }

                    //获取合约
                    result = contractDAL.Get(user, sub.ContractId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Contract.Model.Contract contract = result.ReturnValue as NFMT.Contract.Model.Contract;
                    if (contract == null || contract.ContractId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "关联合约不存在";
                        return result;
                    }

                    if (contract.TradeDirection == (int)NFMT.Contract.TradeDirectionEnum.Buy)
                        getPricingApply.PricingDirection = (int)NFMT.DoPrice.PricingDirection.空头;
                    else
                        getPricingApply.PricingDirection = (int)NFMT.DoPrice.PricingDirection.多头;

                    result = pricingApplyDAL.Update(user, getPricingApply);
                    if (result.ResultStatus != 0)
                        return result;

                    //作废明细
                    result = pricingApplyDetailDAL.InvalidAll(user, getPricingApply.PricingApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    //写入明细
                    foreach (Model.PricingApplyDetail detail in pricingApplyDetails)
                    {
                        detail.PricingApplyId = getPricingApply.PricingApplyId;
                        detail.DetailStatus = StatusEnum.已生效;

                        result = pricingApplyDetailDAL.Insert(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception e)
            {
                result.ResultStatus = -1;
                result.Message = e.Message;
            }

            return result;
        }
예제 #2
0
        public ResultModel Complete(UserModel user, int delayId)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //获取点价延期
                    result = pricingapplydelayDAL.Get(user, delayId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.DoPrice.Model.PricingApplyDelay pricingApplyDelay = result.ReturnValue as NFMT.DoPrice.Model.PricingApplyDelay;
                    if (pricingApplyDelay == null || pricingApplyDelay.DelayId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "点价延期验证失败";
                        return result;
                    }

                    //将延期信息更新到点价申请上
                    DAL.PricingApplyDAL pricingApplyDAL = new PricingApplyDAL();
                    result = pricingApplyDAL.UpdateDelayInfo(user, pricingApplyDelay);
                    if (result.ResultStatus != 0)
                        return result;

                    result = pricingapplydelayDAL.Complete(user, pricingApplyDelay);
                    if (result.ResultStatus != 0)
                        return result;

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
예제 #3
0
        public ResultModel Invalid(UserModel user, int pricingApplyId)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.PricingApplyDAL pricingApplyDAL = new PricingApplyDAL();
                NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
                DAL.PricingApplyDetailDAL pricingApplyDetailDAL = new PricingApplyDetailDAL();

                using (System.Transactions.TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //获取点价申请
                    result = pricingApplyDAL.Get(user, pricingApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.DoPrice.Model.PricingApply pricingApply = result.ReturnValue as NFMT.DoPrice.Model.PricingApply;
                    if (pricingApply == null || pricingApply.PricingApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "点价申请验证失败";
                        return result;
                    }

                    //获取申请
                    result = applyDAL.Get(user, pricingApply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;
                    NFMT.Operate.Model.Apply apply = result.ReturnValue as NFMT.Operate.Model.Apply;
                    if (apply == null || apply.ApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "申请获取失败";
                        return result;
                    }

                    //作废申请
                    result = applyDAL.Invalid(user, apply);
                    if (result.ResultStatus != 0)
                        return result;

                    //作废明细
                    result = pricingApplyDetailDAL.InvalidAll(user, pricingApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
예제 #4
0
        public ResultModel Confirm(UserModel user, int pricingApplyId)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.PricingApplyDAL pricingApplyDAL = new PricingApplyDAL();
                Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
                DAL.PricingApplyDetailDAL pricingApplyDetailDAL = new PricingApplyDetailDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证点价申请
                    result = pricingApplyDAL.Get(user, pricingApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.PricingApply pricingApply = result.ReturnValue as Model.PricingApply;
                    if (pricingApply == null || pricingApply.PricingApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "点价申请不存在";
                        return result;
                    }

                    //验证主申请
                    result = applyDAL.Get(user, pricingApply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Operate.Model.Apply apply = result.ReturnValue as Operate.Model.Apply;
                    if (apply == null || apply.ApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "主申请不存在";
                        return result;
                    }

                    //验证是否执行完成
                    result = pricingApplyDAL.CheckPledgeCanConfirm(user, pricingApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Common.StatusEnum status = (Common.StatusEnum)result.ReturnValue;

                    //获取已生效点价申请明细
                    result = pricingApplyDetailDAL.Load(user, pricingApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.PricingApplyDetail> details = result.ReturnValue as List<Model.PricingApplyDetail>;
                    if (details == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取点价申请明细失败";
                        return result;
                    }

                    //主申请更新状态至已完成
                    if (status == StatusEnum.已完成)
                        result = applyDAL.Confirm(user, apply);
                    else if (status == StatusEnum.部分完成)
                        result = applyDAL.PartiallyConfirm(user, apply);
                    else
                    {
                        result.ResultStatus = -1;
                        result.Message = "更新主申请状态失败";
                        return result;
                    }
                    if (result.ResultStatus != 0)
                        return result;

                    //点价申请明细更新状态至已完成
                    foreach (Model.PricingApplyDetail detail in details)
                    {
                        //点价申请明细更新状态至已完成
                        result = pricingApplyDetailDAL.Confirm(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
예제 #5
0
        public ResultModel Create(UserModel user, NFMT.Operate.Model.Apply apply, NFMT.DoPrice.Model.PricingApply pricingApply, List<NFMT.DoPrice.Model.PricingApplyDetail> pricingApplyDetails)
        {
            ResultModel result = new ResultModel();
            NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
            DAL.PricingApplyDAL pricingApplyDAL = new PricingApplyDAL();
            DAL.PricingApplyDetailDAL pricingApplyDetailDAL = new PricingApplyDetailDAL();
            NFMT.Contract.DAL.ContractSubDAL subDAL = new Contract.DAL.ContractSubDAL();
            NFMT.Contract.DAL.ContractDAL contractDAL = new Contract.DAL.ContractDAL();
            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    NFMT.User.Model.Department dept = NFMT.User.UserProvider.Departments.FirstOrDefault(temp => temp.DeptId == apply.ApplyDept);
                    if (dept == null || dept.DeptId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "申请部门不存在";
                        return result;
                    }

                    //新增主申请
                    apply.EmpId = user.EmpId;
                    apply.ApplyTime = DateTime.Now;
                    apply.ApplyType = NFMT.Operate.ApplyType.PricingApply;
                    apply.ApplyDept = dept.DeptId;
                    result = applyDAL.Insert(user, apply);
                    if (result.ResultStatus != 0)
                        return result;
                    int applyId = (int)result.ReturnValue;
                    pricingApply.ApplyId = applyId;

                    //验证子合约
                    result = subDAL.Get(user, pricingApply.SubContractId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Contract.Model.ContractSub sub = result.ReturnValue as NFMT.Contract.Model.ContractSub;
                    if (sub == null || sub.SubId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "子合约不存在";
                        return result;
                    }

                    if (sub.SubStatus != StatusEnum.已生效)
                    {
                        result.ResultStatus = -1;
                        result.Message = "子合约状态非已生效,不能进行点价申请";
                        return result;
                    }

                    //decimal missRate = Convert.ToDecimal(0.05);
                    //if (pricingApply.PricingWeight > sub.SignAmount)
                    //{
                    //    result.ResultStatus = -1;
                    //    result.Message = "点价重量超过子合约签订数量";
                    //    return result;
                    //}

                    //获取合约
                    result = contractDAL.Get(user, sub.ContractId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Contract.Model.Contract contract = result.ReturnValue as NFMT.Contract.Model.Contract;
                    if (contract == null || contract.ContractId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "关联合约不存在";
                        return result;
                    }

                    if (contract.TradeDirection == (int)NFMT.Contract.TradeDirectionEnum.Buy)
                        pricingApply.PricingDirection = (int)NFMT.DoPrice.PricingDirection.空头;
                    else
                        pricingApply.PricingDirection = (int)NFMT.DoPrice.PricingDirection.多头;

                    //新增点价申请
                    result = pricingApplyDAL.Insert(user, pricingApply);
                    if (result.ResultStatus != 0)
                        return result;

                    int pricingApplyId = (int)result.ReturnValue;

                    foreach (Model.PricingApplyDetail detail in pricingApplyDetails)
                    {
                        detail.PricingApplyId = pricingApplyId;
                        detail.DetailStatus = StatusEnum.已生效;
                        result = pricingApplyDetailDAL.Insert(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception e)
            {
                result.ResultStatus = -1;
                result.Message = e.Message;
            }

            return result;
        }
예제 #6
0
        public ResultModel Goback(UserModel user, int pricingApplyId)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.PricingApplyDAL pricingApplyDAL = new PricingApplyDAL();
                NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();

                using (System.Transactions.TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //获取点价申请
                    result = pricingApplyDAL.Get(user, pricingApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.DoPrice.Model.PricingApply pricingApply = result.ReturnValue as NFMT.DoPrice.Model.PricingApply;
                    if (pricingApply == null || pricingApply.PricingApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "点价申请验证失败";
                        return result;
                    }

                    //获取申请
                    result = applyDAL.Get(user, pricingApply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;
                    NFMT.Operate.Model.Apply apply = result.ReturnValue as NFMT.Operate.Model.Apply;
                    if (apply == null || apply.ApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "申请获取失败";
                        return result;
                    }

                    //撤返申请
                    result = applyDAL.Goback(user, apply);
                    if (result.ResultStatus != 0)
                        return result;

                    //工作流任务关闭
                    WorkFlow.DAL.DataSourceDAL sourceDAL = new WorkFlow.DAL.DataSourceDAL();
                    result = sourceDAL.SynchronousStatus(user, apply);
                    if (result.ResultStatus != 0)
                        return result;

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
예제 #7
0
        public ResultModel ConfirmCancel(UserModel user, int pricingApplyId)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.PricingApplyDAL pricingApplyDAL = new PricingApplyDAL();
                DAL.PricingApplyDetailDAL pricingApplyDetailDAL = new PricingApplyDetailDAL();
                Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证点价申请
                    result = pricingApplyDAL.Get(user, pricingApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.PricingApply pricingApply = result.ReturnValue as Model.PricingApply;
                    if (pricingApply == null || pricingApply.PricingApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "点价申请不存在";
                        return result;
                    }

                    //验证主申请
                    result = applyDAL.Get(user, pricingApply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Operate.Model.Apply apply = result.ReturnValue as Operate.Model.Apply;
                    if (apply == null || apply.ApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "主申请不存在";
                        return result;
                    }

                    //主申请状态更新至已生效
                    result = applyDAL.ConfirmCancel(user, apply);
                    if (result.ResultStatus != 0)
                        return result;

                    //点价申请明细,在已完成状态下的更新至已生效
                    //获取已关闭的明细
                    result = pricingApplyDetailDAL.Load(user, pricingApply.PricingApplyId, Common.StatusEnum.已完成);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.PricingApplyDetail> details = result.ReturnValue as List<Model.PricingApplyDetail>;
                    if (details == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取申请明细失败";
                        return result;
                    }

                    foreach (Model.PricingApplyDetail detail in details)
                    {
                        result = pricingApplyDetailDAL.ConfirmCancel(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
예제 #8
0
파일: PricingBLL.cs 프로젝트: weiliji/NFMT
        public ResultModel Update(UserModel user, Model.Pricing pricing, List<Model.PricingDetail> pricingDetails)
        {
            ResultModel result = new ResultModel();
            DAL.PricingDetailDAL pricingDetailDAL = new PricingDetailDAL();
            DAL.PricingApplyDAL pricingApplyDAL = new PricingApplyDAL();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = pricingDAL.Get(user, pricing.PricingId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.Pricing resPricing = result.ReturnValue as Model.Pricing;
                    if (resPricing == null || resPricing.PricingId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "验证数据失败";
                        return result;
                    }

                    //获取点价申请
                    result = pricingApplyDAL.Get(user, pricing.PricingApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.PricingApply pricingApply = result.ReturnValue as Model.PricingApply;
                    if (pricingApply == null || pricingApply.PricingApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "对应点价申请不存在";
                        return result;
                    }

                    result = pricingDAL.IsWeightCanPricing(user, pricing.PricingApplyId, pricing.FuturesCodeId, pricingApply.PricingWeight, pricing.PricingWeight, true, resPricing.PricingWeight);
                    if (result.ResultStatus != 0)
                        return result;

                    resPricing.PricingWeight = pricing.PricingWeight;
                    resPricing.MUId = pricing.MUId;
                    resPricing.ExchangeId = pricing.ExchangeId;
                    resPricing.FuturesCodeEndDate = pricing.FuturesCodeEndDate;
                    resPricing.FuturesCodeId = pricing.FuturesCodeId;
                    resPricing.SpotQP = pricing.SpotQP;
                    resPricing.DelayFee = pricing.DelayFee;
                    resPricing.Spread = pricing.Spread;
                    resPricing.OtherFee = pricing.OtherFee;
                    resPricing.AvgPrice = pricing.AvgPrice;
                    resPricing.PricingTime = pricing.PricingTime;
                    resPricing.CurrencyId = pricing.CurrencyId;
                    resPricing.Pricinger = pricing.Pricinger;
                    resPricing.AssertId = pricing.AssertId;
                    resPricing.FinalPrice = pricing.FinalPrice;

                    result = pricingDAL.Update(user, resPricing);
                    if (result.ResultStatus != 0)
                        return result;

                    result = pricingDetailDAL.InvalidAll(user, pricing.PricingId);
                    if (result.ResultStatus != 0)
                        return result;

                    foreach (Model.PricingDetail detail in pricingDetails)
                    {
                        detail.PricingId = pricing.PricingId;
                        detail.DetailStatus = StatusEnum.已生效;
                        detail.PricingApplyId = resPricing.PricingApplyId;

                        result = pricingDetailDAL.Insert(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            finally
            {
                if (result.ResultStatus != 0)
                    this.Log.ErrorFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue);
                else if (this.Log.IsInfoEnabled)
                    this.Log.InfoFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue);
            }

            return result;
        }
예제 #9
0
파일: PricingBLL.cs 프로젝트: weiliji/NFMT
        public ResultModel GoBack(UserModel user, int pricingId)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = pricingDAL.Get(user, pricingId);
                    if (result.ResultStatus != 0)
                        return result;
                    Model.Pricing pricing = result.ReturnValue as Pricing;
                    if (pricing == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "该数据不存在,不能撤返";
                        return result;
                    }

                    //获取点价申请实体
                    DAL.PricingApplyDAL pricingApplyDAL = new PricingApplyDAL();
                    result = pricingApplyDAL.Get(user, pricing.PricingApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.PricingApply pricingApply = result.ReturnValue as Model.PricingApply;

                    //获取申请实体
                    NFMT.Operate.DAL.ApplyDAL applyDAl = new Operate.DAL.ApplyDAL();
                    result = applyDAl.Get(user, pricingApply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Operate.Model.Apply apply = result.ReturnValue as NFMT.Operate.Model.Apply;
                    if (apply.Status != StatusEnum.已生效)
                    {
                        result.ResultStatus = -1;
                        result.Message = "点价对应的申请非已生效,不能进行撤返操作";
                        return result;
                    }

                    result = pricingDAL.Goback(user, pricing);
                    if (result.ResultStatus != 0)
                        return result;

                    //同步工作流状态
                    NFMT.WorkFlow.BLL.DataSourceBLL dataSourceBLL = new WorkFlow.BLL.DataSourceBLL();
                    result = dataSourceBLL.SynchronousStatus(user, pricing);
                    if (result.ResultStatus != 0)
                        return result;

                    if (result.ResultStatus == 0)
                        result.Message = "撤返成功";
                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            finally
            {
                if (result.ResultStatus != 0)
                    log.ErrorFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue);
                else if (log.IsInfoEnabled)
                    log.InfoFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue);
            }

            return result;
        }
예제 #10
0
파일: PricingBLL.cs 프로젝트: weiliji/NFMT
        public ResultModel Create(UserModel user, Model.Pricing pricing, List<Model.PricingDetail> pricingDetails)
        {
            ResultModel result = new ResultModel();
            DAL.PricingDetailDAL pricingDetailDAL = new PricingDetailDAL();
            DAL.PricingApplyDAL pricingApplyDAL = new PricingApplyDAL();
            DAL.PricingApplyDetailDAL applyDetail = new PricingApplyDetailDAL();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //获取点价申请
                    result = pricingApplyDAL.Get(user, pricing.PricingApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.PricingApply pricingApply = result.ReturnValue as Model.PricingApply;
                    if (pricingApply == null || pricingApply.PricingApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "对应点价申请不存在";
                        return result;
                    }

                    if (pricing.AvgPrice < pricingApply.MinPrice || pricing.AvgPrice > pricingApply.MaxPrice)
                    {
                        result.ResultStatus = -1;
                        result.Message = "期货成交价不在点价申请价格范围内";
                        return result;
                    }

                    result = pricingDAL.IsWeightCanPricing(user, pricing.PricingApplyId, pricing.FuturesCodeId, pricingApply.PricingWeight, pricing.PricingWeight, false, 0);
                    if (result.ResultStatus != 0)
                        return result;

                    pricing.PricingDirection = pricingApply.PricingDirection;
                    pricing.PricingStatus = StatusEnum.已录入;
                    result = pricingDAL.Insert(user, pricing);

                    if (result.ResultStatus != 0)
                        return result;
                    int pricingId = (int)result.ReturnValue;

                    foreach (Model.PricingDetail detail in pricingDetails)
                    {
                        detail.PricingId = pricingId;
                        detail.DetailStatus = StatusEnum.已生效;
                        result = pricingDetailDAL.Insert(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            finally
            {
                if (result.ResultStatus != 0)
                    this.Log.ErrorFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue);
                else if (this.Log.IsInfoEnabled)
                    this.Log.InfoFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue);
            }

            return result;
        }
예제 #11
0
파일: PricingBLL.cs 프로젝트: weiliji/NFMT
        public ResultModel CompleteCancel(UserModel user, int pricingId)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.PricingDetailDAL pricingDetailDAL = new PricingDetailDAL();
                DAL.PricingApplyDAL pricingApplyDAL = new PricingApplyDAL();
                Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证点价
                    result = pricingDAL.Get(user, pricingId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.Pricing pricing = result.ReturnValue as Pricing;
                    if (pricing == null || pricing.PricingId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "该数据不存在,不能进行执行完成取消操作";
                        return result;
                    }

                    //点价完成取消
                    result = pricingDAL.CompleteCancel(user, pricing);
                    if (result.ResultStatus != 0)
                        return result;

                    //获取已完成点价明细
                    result = pricingDetailDAL.Load(user, pricing.PricingId, Common.StatusEnum.已完成);
                    if (result.ResultStatus != 0)
                        return result;
                    List<Model.PricingDetail> details = result.ReturnValue as List<Model.PricingDetail>;
                    if (details == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取点价明细错误";
                        return result;
                    }

                    //将所有已完成点价明细更新至已生效
                    foreach (Model.PricingDetail detail in details)
                    {
                        result = pricingDetailDAL.CompleteCancel(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }