Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public string FinancingPledgeApplyUpdate(string userStr, string pledgeApplyStr, string detailsStr)
        {
            ResultModel result = new ResultModel();
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    UserModel user = serializer.Deserialize<UserModel>(userStr);
                    PledgeApply pledgeApply = serializer.Deserialize<PledgeApply>(pledgeApplyStr);
                    List<PledgeApplyStockDetail> details = serializer.Deserialize<List<PledgeApplyStockDetail>>(detailsStr);

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

                    PledgeApply pledgeApplyGet = result.ReturnValue as PledgeApply;

                    pledgeApplyGet.DeptId = pledgeApply.DeptId;
                    pledgeApplyGet.ApplyTime = pledgeApply.ApplyTime;
                    pledgeApplyGet.FinancingBankId = pledgeApply.FinancingBankId;
                    pledgeApplyGet.FinancingAccountId = pledgeApply.FinancingAccountId;
                    pledgeApplyGet.AssetId = pledgeApply.AssetId;
                    pledgeApplyGet.SwitchBack = pledgeApply.SwitchBack;
                    pledgeApplyGet.ExchangeId = pledgeApply.ExchangeId;

                    decimal SumNetAmount = 0;
                    int SumHands = 0;
                    if (details != null && details.Any())
                    {
                        foreach (PledgeApplyStockDetail detail in details)
                        {
                            SumNetAmount += detail.NetAmount;
                            SumHands += detail.Hands;
                        }
                    }

                    pledgeApplyGet.SumNetAmount = SumNetAmount;
                    pledgeApplyGet.SumHands = SumHands;

                    result = pledgeApplyDAL.Update(user, pledgeApplyGet);
                    if (result.ResultStatus != 0)
                        return serializer.Serialize(result);

                    PledgeApplyStockDetailDAL pledgeApplyStockDetailDAL = new PledgeApplyStockDetailDAL();
                    result = pledgeApplyStockDetailDAL.UpdateDetailStatus(user, pledgeApply.PledgeApplyId, StatusEnum.无效数据);
                    if (result.ResultStatus != 0)
                        return serializer.Serialize(result);

                    StockNoDAL stockNoDAL = new StockNoDAL();
                    int stockId;
                    foreach (PledgeApplyStockDetail detail in details)
                    {
                        result = stockNoDAL.Insert(user, new StockNo()
                        {
                            RefNo = detail.RefNo.Trim(),
                            NetAmount = detail.NetAmount
                        });
                        if (result.ResultStatus != 0)
                            return serializer.Serialize(result);

                        stockId = (int)result.ReturnValue;

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

                    if (result.ResultStatus == 0)
                        result.Message = "质押申请单修改成功";

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

            return serializer.Serialize(result);
        }