Ejemplo n.º 1
0
        public string FinRepoApplyCreate(string userStr, string repoApplyStr, string repoApplyDetailsStr, bool isSubmitAudit)
        {
            ResultModel result = new ResultModel();
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    UserModel user = serializer.Deserialize<UserModel>(userStr);
                    RepoApply repoApply = serializer.Deserialize<RepoApply>(repoApplyStr);
                    List<RepoApplyDetail> details = serializer.Deserialize<List<RepoApplyDetail>>(repoApplyDetailsStr);

                    RepoApplyDAL repoApplyDAL = new RepoApplyDAL();
                    result = repoApplyDAL.Insert(user, repoApply);
                    if (result.ResultStatus != 0)
                        return serializer.Serialize(result);

                    int repoApplyId = (int)result.ReturnValue;

                    RepoApplyDetailDAL repoApplyDetailDAL = new RepoApplyDetailDAL();
                    foreach (RepoApplyDetail detail in details)
                    {
                        detail.RepoApplyId = repoApplyId;
                        detail.PledgeApplyId = repoApply.PledgeApplyId;

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

                    if (result.ResultStatus == 0)
                    {
                        if (isSubmitAudit)
                        {
                            repoApply.RepoApplyId = repoApplyId;

                            AutoSubmit submit = new AutoSubmit();
                            result = submit.Submit(user, repoApply, new RepoApplyTaskProvider(), MasterEnum.赎回申请单审核);
                        }
                        result.Message = "赎回申请单新增成功";
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                this.log.ErrorFormat("FinService出错,出错方法:{0},{1}", "FinRepoApplyCreate", ex.Message);
                result.Message = ex.Message;
                result.ResultStatus = -1;
            }

            return serializer.Serialize(result);
        }
Ejemplo n.º 2
0
        public string FinancingPledgeApplyCreate(UserModel user, PledgeApply pledgeApply, List<PledgeApplyStockDetail> details, bool isSubmitAudit)
        {
            ResultModel result = new ResultModel();
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    decimal SumNetAmount = 0;
                    int SumHands = 0;
                    if (details != null && details.Any())
                    {
                        foreach (PledgeApplyStockDetail detail in details)
                        {
                            SumNetAmount += detail.NetAmount;
                            SumHands += detail.Hands;
                        }
                    }

                    pledgeApply.SumNetAmount = SumNetAmount;
                    pledgeApply.SumHands = SumHands;

                    PledgeApplyDAL pledgeApplyDAL = new PledgeApplyDAL();
                    result = pledgeApplyDAL.Insert(user, pledgeApply);
                    if (result.ResultStatus != 0)
                        return serializer.Serialize(result);

                    int pledgeApplyId = (int)result.ReturnValue;

                    PledgeApplyStockDetailDAL pledgeApplyStockDetailDAL = new PledgeApplyStockDetailDAL();
                    StockNoDAL stockNoDAL = new StockNoDAL();
                    int stockId;
                    foreach (PledgeApplyStockDetail detail in details)
                    {
                        result = stockNoDAL.Insert(user, new StockNo()
                        {
                            RefNo = detail.RefNo.Trim(),
                            NetAmount = detail.NetAmount
                        });
                        stockId = (int)result.ReturnValue;

                        detail.RefNo = detail.RefNo.Trim();
                        detail.StockId = stockId;
                        detail.PledgeApplyId = pledgeApplyId;
                        result = pledgeApplyStockDetailDAL.Insert(user, detail);
                        if (result.ResultStatus != 0)
                            return serializer.Serialize(result);
                    }

                    if (result.ResultStatus == 0)
                    {
                        if (isSubmitAudit)
                        {
                            pledgeApply.PledgeApplyId = pledgeApplyId;

                            AutoSubmit submit = new AutoSubmit();
                            result = submit.Submit(user, pledgeApply, new PledgeApplyTaskProvider(), MasterEnum.质押申请单审核);
                        }

                        result.Message = "质押申请单新增成功";
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                this.log.ErrorFormat("FinService出错,出错方法:{0},{1}", "FinancingPledgeApplyCreate", ex.Message);
                result.Message = ex.Message;
                result.ResultStatus = -1;
            }

            return serializer.Serialize(result);
        }