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 Common.ResultModel GetEmailInfo(Common.UserModel user)
        {
            Common.ResultModel result = new Common.ResultModel();
            StringBuilder sb = new StringBuilder();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    switch (m_finType)
                    {
                        case FinType.质押:
                            sb.Clear();
                            DAL.PledgeApplyDAL pledgeApplyDAL = new DAL.PledgeApplyDAL();
                            result = pledgeApplyDAL.Get(user, m_id);
                            if (result.ResultStatus != 0)
                                return result;

                            Model.PledgeApply pledgeApply = result.ReturnValue as Model.PledgeApply;
                            if (pledgeApply == null)
                            {
                                result.ResultStatus = -1;
                                result.Message = "获取质押申请单失败";
                                return result;
                            }

                            NFMT.Data.Model.Bank bank = NFMT.Data.BasicDataProvider.Banks.SingleOrDefault(a => a.BankId == pledgeApply.FinancingBankId);
                            sb.Append(GetBanInfo(bank));

                            DAL.PledgeApplyCashDetailDAL pledgeApplyCashDetailDAL = new DAL.PledgeApplyCashDetailDAL();
                            result = pledgeApplyCashDetailDAL.LoadByPledgeApplyId(user, m_id);
                            if (result.ResultStatus != 0)
                                return result;

                            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;

                            foreach (System.Data.DataRow dr in dt.Rows)
                            {
                                sb.Append("<span>");
                                sb.AppendFormat("We short {0} lots Copper at price  USD{1}/MT, prompt date: {2} under contract {3};", dr["Hands"], dr["Price"], Convert.ToDateTime(dr["ExpiringDate"]).ToString("MMMM dd, yyyy", new CultureInfo("en-us")), dr["StockContractNo"]);
                                sb.Append("</span>");
                                sb.Append("<br>");
                            }

                            break;
                        case FinType.赎回:
                            sb.Clear();
                            DAL.RepoApplyDAL repoApplyDAL = new DAL.RepoApplyDAL();
                            result = repoApplyDAL.GetByPledgeApplyId(user, m_id);
                            if (result.ResultStatus != 0)
                                return result;
                            int bankId = (int)result.ReturnValue;

                            bank = NFMT.Data.BasicDataProvider.Banks.SingleOrDefault(a => a.BankId == bankId);
                            sb.Append(GetBanInfo(bank));

                            DAL.RepoApplyDetailDAL repoApplyDetailDAL = new DAL.RepoApplyDetailDAL();
                            result = repoApplyDetailDAL.LoadByRepoApplyId(user, m_id);
                            if (result.ResultStatus != 0)
                                return result;

                            dt = result.ReturnValue as System.Data.DataTable;

                            foreach (System.Data.DataRow dr in dt.Rows)
                            {
                                sb.Append("<span>");
                                sb.AppendFormat("We long {0} lots Copper at price  USD{1}/MT, prompt date: {2} under contract {3};", dr["Hands"], dr["Price"], Convert.ToDateTime(dr["ExpiringDate"]).ToString("MMMM dd, yyyy", new CultureInfo("en-us")), dr["StockContractNo"]);
                                sb.Append("</span>");
                                sb.Append("<br>");
                            }
                            break;
                        default:
                            break;
                    }

                    if (result.ResultStatus == 0)
                    {
                        scope.Complete();
                        result.ReturnValue = sb.ToString();
                    }
                }
            }
            catch(Exception e)
            {
                result.ResultStatus = -1;
                result.Message = e.Message;
                result.ReturnValue = sb.Clear();
            }

            return result;
        }
Ejemplo n.º 3
0
        public string FinancingRepoApplyUpdateHands(string userStr, string detailsStr, int repoApplyId)
        {
            ResultModel result = new ResultModel();
            JavaScriptSerializer serializer = new JavaScriptSerializer();

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

                    int sumHands = 0;

                    RepoApplyDetailDAL repoApplyDetailDAL = new RepoApplyDetailDAL();
                    RepoApplyDetail repoApplyDetail = null;
                    foreach (RepoApplyDetail detail in details)
                    {
                        sumHands += detail.Hands;

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

                        repoApplyDetail = result.ReturnValue as RepoApplyDetail;

                        repoApplyDetail.Hands = detail.Hands;

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

                    RepoApplyDAL repoApplyDAL = new RepoApplyDAL();
                    result = repoApplyDAL.Get(user, repoApplyId);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    RepoApply repoApply = result.ReturnValue as RepoApply;

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

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

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

            return serializer.Serialize(result);
        }
Ejemplo n.º 4
0
        public string FinancingRepoApplyInvalid(string userStr, int repoApplyId)
        {
            ResultModel result = new ResultModel();
            JavaScriptSerializer serializer = new JavaScriptSerializer();

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

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    RepoApplyDAL repoApplyDAL = new RepoApplyDAL();
                    result = repoApplyDAL.Get(user, repoApplyId);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    RepoApply repoApply = result.ReturnValue as RepoApply;

                    result = repoApplyDAL.Invalid(user, repoApply);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    RepoApplyDetailDAL repoApplyDetailDAL = new RepoApplyDetailDAL();
                    result = repoApplyDetailDAL.InvalidAll(user, repoApplyId);
                    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}", "FinancingRepoApplyInvalid", e.Message);
                return e.Message;
            }
        }
Ejemplo n.º 5
0
        public string FinancingRepoApplyIdCompleteCancel(string userStr, int repoApplyId)
        {
            ResultModel result = new ResultModel();
            JavaScriptSerializer serializer = new JavaScriptSerializer();

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

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    RepoApplyDAL repoApplyDAL = new RepoApplyDAL();
                    result = repoApplyDAL.Get(user, repoApplyId);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    RepoApply repoApply = result.ReturnValue as RepoApply;

                    result = repoApplyDAL.CompleteCancel(user, repoApply);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    //完成撤销赎回申请单明细
                    RepoApplyDetailDAL repoApplyDetailDAL = new RepoApplyDetailDAL();
                    result = repoApplyDetailDAL.LoadByRepoApplyId(user, repoApplyId, StatusEnum.已完成);
                    if (result.ResultStatus != 0)
                        return result.Message;

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

                    foreach (RepoApplyDetail detail in details)
                    {
                        result = repoApplyDetailDAL.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}", "FinancingRepoApplyIdCompleteCancel", e.Message);
                return e.Message;
            }
        }
Ejemplo n.º 6
0
        public string FinancingRepoApplyGoBack(string userStr, int repoApplyId)
        {
            ResultModel result = new ResultModel();
            JavaScriptSerializer serializer = new JavaScriptSerializer();

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

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    RepoApplyDAL repoApplyDAL = new RepoApplyDAL();
                    result = repoApplyDAL.Get(user, repoApplyId);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    RepoApply repoApply = result.ReturnValue as RepoApply;

                    result = repoApplyDAL.Goback(user, repoApply);
                    if (result.ResultStatus != 0)
                        return result.Message;

                    //工作流任务关闭
                    DataSourceDAL sourceDAL = new DataSourceDAL();
                    result = sourceDAL.SynchronousStatus(user, repoApply);
                    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}", "FinancingRepoApplyGoBack", e.Message);
                return e.Message;
            }
        }
Ejemplo n.º 7
0
        public string FinRepoApplyUpdate(string userStr, string repoApplyStr, string repoApplyDetailsStr)
        {
            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.Get(user, repoApply.RepoApplyId);
                    if (result.ResultStatus != 0)
                        return serializer.Serialize(result);

                    RepoApply repoApplyGet = result.ReturnValue as RepoApply;
                    repoApplyGet.SumNetAmount = repoApply.SumNetAmount;
                    repoApplyGet.SumHands = repoApply.SumHands;

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

                    RepoApplyDetailDAL repoApplyDetailDAL = new RepoApplyDetailDAL();
                    result = repoApplyDetailDAL.UpdateStatus(user, repoApply.RepoApplyId, NFMT.Common.StatusEnum.无效数据);
                    if (result.ResultStatus != 0)
                        return serializer.Serialize(result);

                    foreach (RepoApplyDetail detail in details)
                    {
                        detail.RepoApplyId = repoApply.RepoApplyId;
                        detail.PledgeApplyId = repoApply.PledgeApplyId;

                        result = repoApplyDetailDAL.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}", "FinRepoApplyUpdate", ex.Message);
                result.Message = ex.Message;
                result.ResultStatus = -1;
            }

            return serializer.Serialize(result);
        }