示例#1
0
        /// <summary>
        /// 还款
        /// </summary>
        /// <param name="msg"></param>
        private static void Repay(RepayRespMsg msg)
        {
            try
            {
                //检查请求处理结果
                if (msg.CheckResult())
                {
                    //检查签名
                    if (msg.CheckSignature())
                    {
                        Agp2pDataContext context = new Agp2pDataContext();
                        //异步返回才执行,内网测试使用同步
#if DEBUG
                        if (msg.Sync)
                        {
#endif
#if !DEBUG
                        if (!msg.Sync)
                        {
#endif
                            var req = context.li_pay_request_log.SingleOrDefault(r => r.id == msg.RequestId);
                            if (req != null)
                            {
                                //查找对应的项目
                                var pro = context.li_projects.SingleOrDefault(p => p.id == msg.ProjectCode);
                                if (pro != null)
                                {
                                    if (!string.IsNullOrEmpty(req.remarks))
                                    {
                                        //活期项目不需要生成还款记录
                                        if (!msg.HuoqiRepay)
                                        {
                                            var dic = Utils.UrlParamToData(req.remarks);
                                            int repayId = Utils.StrToInt(dic["repayTaskId"], 0);
                                            context.GainLoanerRepayment(DateTime.Now, repayId, (int) msg.UserIdIdentity,
                                                Utils.StrToDecimal(msg.Sum, 0));

                                            //如果是手动还款立刻发送本息到账请求 TODO 是否需要?
                                            if (!msg.AutoRepay)
                                            {
                                                RequestApiHandle.SendReturnPrinInte(msg.ProjectCode, msg.Sum, repayId,
                                                    Utils.StrToBool(dic["isEarly"], false), false);
                                            }
                                        }
                                        msg.HasHandle = true;
                                    }
                                    else
                                        msg.Remarks = "请求没有包含还款计划信息!";
                                }
                                else
                                    msg.Remarks = "没有找到平台项目,项目编号为:" + msg.ProjectCode;
                            }
                            else
                                msg.Remarks = "没有找到对应的还款请求,请求编号为:" + msg.RequestId;
                        }
                    }
                }
            }
            catch (ChangeConflictException)
            {
                MessageBus.Main.Publish(msg);
            }
            catch (Exception ex)
            {
                msg.Remarks = "内部错误:" + ex.Message;
            }
        }
示例#2
0
        protected void excBtn_OnClick(object sender, EventArgs e)
        {
            string requestId = ((LinkButton)sender).CommandArgument;
            var    request   = context.li_pay_request_log.SingleOrDefault(r => r.id == requestId);

            if (request != null)
            {
                var project = context.li_projects.SingleOrDefault(p => p.id == request.project_id);
                switch (request.api)
                {
#if DEBUG
                //个人自动账户/银行还款开通
                case (int)Agp2pEnums.SumapayApiEnum.AcReO:
                case (int)Agp2pEnums.SumapayApiEnum.AbReO:
                    if (project != null)
                    {
                        project.autoRepay = true;
                        context.SubmitChanges();
                    }
                    break;

                //个人自动还款取消
                case (int)Agp2pEnums.SumapayApiEnum.ClRep:
                    if (project != null)
                    {
                        project.autoRepay = false;
                        context.SubmitChanges();
                    }
                    break;

                //个人网银/一键充值
                case (int)Agp2pEnums.SumapayApiEnum.WeRec:
                case (int)Agp2pEnums.SumapayApiEnum.WhRec:
                case (int)Agp2pEnums.SumapayApiEnum.WhReM:
                    var trans = context.li_bank_transactions.SingleOrDefault(u => u.no_order == requestId);
                    if (trans?.status == (int)Agp2pEnums.BankTransactionStatusEnum.Acting)
                    {
                        context.ConfirmBankTransaction(trans.id, null);
                    }
                    break;

                //个人提现
                case (int)Agp2pEnums.SumapayApiEnum.Wdraw:
                case (int)Agp2pEnums.SumapayApiEnum.WdraM:
                    var transT = context.li_bank_transactions.SingleOrDefault(u => u.no_order == requestId);
                    if (transT?.status == (int)Agp2pEnums.BankTransactionStatusEnum.Acting)
                    {
                        context.ConfirmBankTransaction(transT.id, null);
                    }
                    break;

                //普通/集合项目放款
                case (int)Agp2pEnums.SumapayApiEnum.ALoan:
                case (int)Agp2pEnums.SumapayApiEnum.CLoan:
                    if (project != null)
                    {
                        if (project.IsHuoqiProject())
                        {
                            TransactionFacade.MakeLoan(context, DateTime.Now, project, project.li_risks.li_loaners.user_id);
                        }
                        else
                        {
                            context.StartRepayment(project.id);
                        }
                    }
                    break;

                //个人自动还款普通/集合项目
                case (int)Agp2pEnums.SumapayApiEnum.AcRep:
                case (int)Agp2pEnums.SumapayApiEnum.AbRep:
                    if (!string.IsNullOrEmpty(request.remarks))
                    {
                        if (project != null && !project.IsHuoqiProject() && !project.IsNewbieProject1())
                        {
                            var dic       = Utils.UrlParamToData(request.remarks);
                            int repayId   = Utils.StrToInt(dic["repayTaskId"], 0);
                            var repayTask = context.li_repayment_tasks.SingleOrDefault(r => r.id == repayId);
                            if (repayTask != null)
                            {
                                context.GainLoanerRepayment(DateTime.Now, repayId, (int)request.user_id, repayTask.repay_principal + repayTask.repay_interest);
                            }
                        }
                    }
                    break;

                //普通/集合项目本息到账
                case (int)Agp2pEnums.SumapayApiEnum.RetPt:
                case (int)Agp2pEnums.SumapayApiEnum.RetCo:
                    if (project != null && !project.IsHuoqiProject() && !project.IsNewbieProject1())
                    {
                        if (!string.IsNullOrEmpty(request.remarks))
                        {
                            var dic     = Utils.UrlParamToData(request.remarks);
                            int repayId = Utils.StrToInt(dic["repayTaskId"], 0);
                            context.ExecuteRepaymentTask(repayId);
                        }
                    }
                    break;
#endif
                default:
                    throw new NotImplementedException("该接口操作暂不能在平台单方面执行。");
                }
            }
        }