Ejemplo n.º 1
0
        public static void BuyClaim(string projectName, string userName, decimal amount)
        {
            var context = new Agp2pDataContext();
            var project = context.li_projects.Single(p => p.title == projectName);
            var user    = context.dt_users.Single(u => u.user_name == userName);

            var preBuyClaim = project.li_claims.Where(
                c =>
                c.status == (int)Agp2pEnums.ClaimStatusEnum.NeedTransfer &&
                c.IsLeafClaim()).OrderBy(c => Math.Abs(c.principal - amount)).First();

            TransactionFacade.BuyClaim(context, preBuyClaim.id, user.id, amount);

            context.SubmitChanges();
        }
        protected void btnBuy_OnClick(object sender, EventArgs e)
        {
            var buyAmount = Request["__EVENTARGUMENT"];
            int claimId   = Convert.ToInt32(((LinkButton)sender).CommandArgument);

            selectedAgent = Convert.ToInt32(ddlAgent.SelectedValue);

            try
            {
                TransactionFacade.BuyClaim(context, claimId, selectedAgent, Convert.ToDecimal(buyAmount));
                context = new Agp2pDataContext();
                RptBind();
                JscriptMsg("买入债权成功", "", "Success");
            }
            catch (Exception ex)
            {
                JscriptMsg("买入债权失败:" + ex.Message, "", "Success");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 债权转让
        /// </summary>
        /// <param name="msg"></param>
        private static void CreditAssignment(CreditAssignmentRespMsg msg)
        {
            try
            {
                //检查请求处理结果
                if (msg.CheckResult())
                {
                    //检查签名
                    if (msg.CheckSignature())
                    {
#if !DEBUG
                        //同步返回平台不做处理
                        if (msg.Result.Equals("00001")) return;
#endif

                        Agp2pDataContext context = new Agp2pDataContext();
                        //查找对应的债权交易流水
                        var trans =
                            context.li_project_transactions.SingleOrDefault(p => p.no_order == msg.OriginalRequestId);
                        if (trans != null)
                        {
                            TransactionFacade.BuyClaim(context,
                                trans.li_claims_invested.OrderByDescending(c => c.createTime)
                                    .First(c => c.status == (int)Agp2pEnums.ClaimStatusEnum.NeedTransfer)
                                    .id, (int)msg.UserIdIdentity,
                                Utils.StrToDecimal(msg.AssignmentSum, 0));
                            msg.HasHandle = true;
                        }
                        else
                        {
                            msg.Remarks = "没有找到平台项目,项目编号为:" + msg.ProjectCode;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                msg.Remarks = "内部错误:" + ex.Message;
            }
        }