Ejemplo n.º 1
0
        public string FinancingPledgeApplyClose(string userStr, int pledgeApplyId)
        {
            ResultModel result = new ResultModel();
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            try
            {
                UserModel user = serializer.Deserialize<UserModel>(userStr);

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    PledgeApplyDAL pledgeApplyDAL = new PledgeApplyDAL();
                    result = pledgeApplyDAL.Get(user, pledgeApplyId);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    PledgeApply pledgeApply = result.ReturnValue as PledgeApply;

                    result = pledgeApplyDAL.Close(user, pledgeApply);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    //关闭质押申请单实货明细
                    PledgeApplyStockDetailDAL pledgeApplyStockDetailDAL = new PledgeApplyStockDetailDAL();
                    result = pledgeApplyStockDetailDAL.UpdateDetailStatus(user, pledgeApplyId, StatusEnum.已关闭);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    if (result.ResultStatus == 0)
                    {
                        scope.Complete();
                        return "执行关闭操作成功";
                    }
                    else
                        return "执行关闭操作失败";
                }
            }
            catch (Exception e)
            {
                this.log.ErrorFormat("FinService出错,出错方法:{0},{1}", "FinancingPledgeApplyClose", e.Message);
                return e.Message;
            }
        }
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);
        }
Ejemplo n.º 3
0
        public string FinancingPledgeApplyUpdateHands(string userStr, string detailsStr, int pledgeApplyId)
        {
            ResultModel result = new ResultModel();
            JavaScriptSerializer serializer = new JavaScriptSerializer();

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

                    int sumHands = 0;

                    PledgeApplyStockDetailDAL pledgeApplyStockDetailDAL = new PledgeApplyStockDetailDAL();
                    PledgeApplyStockDetail pledgeApplyStockDetail = null;
                    foreach (PledgeApplyStockDetail detail in details)
                    {
                        sumHands += detail.Hands;

                        result = pledgeApplyStockDetailDAL.Get(user, detail.StockDetailId);
                        if (result.ResultStatus != 0)
                            return result.Message;

                        pledgeApplyStockDetail = result.ReturnValue as PledgeApplyStockDetail;

                        pledgeApplyStockDetail.PledgeApplyId = detail.PledgeApplyId;
                        pledgeApplyStockDetail.ContractNo = detail.ContractNo;
                        pledgeApplyStockDetail.NetAmount = detail.NetAmount;
                        pledgeApplyStockDetail.StockId = detail.StockId;
                        pledgeApplyStockDetail.RefNo = detail.RefNo;
                        pledgeApplyStockDetail.Deadline = detail.Deadline;
                        pledgeApplyStockDetail.Hands = detail.Hands;
                        pledgeApplyStockDetail.Memo = detail.Memo;

                        result = pledgeApplyStockDetailDAL.Update(user, pledgeApplyStockDetail);
                        if (result.ResultStatus != 0)
                            return result.Message;
                    }

                    PledgeApplyDAL pledgeApplyDAL = new PledgeApplyDAL();
                    result = pledgeApplyDAL.Get(user, pledgeApplyId);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    PledgeApply pledgeApply = result.ReturnValue as PledgeApply;

                    pledgeApply.SumHands = sumHands;
                    result = pledgeApplyDAL.Update(user, pledgeApply);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    if (result.ResultStatus == 0)
                        result.Message = "质押申请单手数更新成功";

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

            return serializer.Serialize(result);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public string FinancingPledgeApplyInvalid(string userStr, int pledgeApplyId)
        {
            ResultModel result;
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            try
            {
                UserModel user = serializer.Deserialize<UserModel>(userStr);

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    PledgeApplyDAL pledgeApplyDAL = new PledgeApplyDAL();
                    result = pledgeApplyDAL.Get(user, pledgeApplyId);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    PledgeApply pledgeApply = result.ReturnValue as PledgeApply;

                    result = pledgeApplyDAL.Invalid(user, pledgeApply);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    PledgeApplyCashDetailDAL pledgeApplyCashDetailDAL = new PledgeApplyCashDetailDAL();
                    result = pledgeApplyCashDetailDAL.InvalidAll(user, pledgeApplyId);
                    //if (result.ResultStatus != 0)
                    //    return result.Message;

                    PledgeApplyStockDetailDAL pledgeApplyStockDetailDAL = new PledgeApplyStockDetailDAL();
                    result = pledgeApplyStockDetailDAL.InvalidAll(user, pledgeApplyId);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    if (result.ResultStatus == 0)
                    {
                        scope.Complete();
                        return "作废成功";
                    }
                    else
                        return "作废失败";
                }
            }
            catch (Exception e)
            {
                this.log.ErrorFormat("FinService出错,出错方法:{0},{1}", "FinancingPledgeApplyInvalid", e.Message);
                return e.Message;
            }
        }
Ejemplo n.º 6
0
        public string FinancingPledgeApplyIdCompleteCancel(string userStr, int pledgeApplyId)
        {
            ResultModel result = new ResultModel();
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            try
            {
                UserModel user = serializer.Deserialize<UserModel>(userStr);

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    PledgeApplyDAL pledgeApplyDAL = new PledgeApplyDAL();
                    result = pledgeApplyDAL.Get(user, pledgeApplyId);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    PledgeApply pledgeApply = result.ReturnValue as PledgeApply;

                    result = pledgeApplyDAL.CompleteCancel(user, pledgeApply);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    //完成撤销质押申请单实货明细
                    PledgeApplyStockDetailDAL pledgeApplyStockDetailDAL = new PledgeApplyStockDetailDAL();
                    result = pledgeApplyStockDetailDAL.LoadByPledgeApplyId(user, pledgeApplyId, StatusEnum.已完成);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    List<PledgeApplyStockDetail> stockDetails = result.ReturnValue as List<PledgeApplyStockDetail>;
                    if (stockDetails == null || !stockDetails.Any())
                        return "获取质押申请单实货明细失败";

                    foreach (PledgeApplyStockDetail detail in stockDetails)
                    {
                        result = pledgeApplyStockDetailDAL.CompleteCancel(user, detail);
                        if (result.ResultStatus != 0)
                            return result.Message;
                    }

                    //完成撤销质押申请单头寸明细
                    PledgeApplyCashDetailDAL pledgeApplyCashDetailDAL = new PledgeApplyCashDetailDAL();
                    result = pledgeApplyCashDetailDAL.LoadByPledgeApplyId(user, pledgeApplyId, StatusEnum.已完成);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    List<PledgeApplyCashDetail> cashDetails = result.ReturnValue as List<PledgeApplyCashDetail>;
                    if (cashDetails == null || !cashDetails.Any())
                        return "获取质押申请单头寸明细失败";

                    foreach (PledgeApplyCashDetail detail in cashDetails)
                    {
                        result = pledgeApplyCashDetailDAL.CompleteCancel(user, detail);
                        if (result.ResultStatus != 0)
                            return result.Message;
                    }

                    if (result.ResultStatus == 0)
                    {
                        scope.Complete();
                        return "执行完成撤销 成功";
                    }
                    else
                        return "执行完成撤销 失败";
                }
            }
            catch (Exception e)
            {
                this.log.ErrorFormat("FinService出错,出错方法:{0},{1}", "FinancingPledgeApplyIdCompleteCancel", e.Message);
                return e.Message;
            }
        }