/// <summary> /// 个人投标/自动投标 响应 /// </summary> /// <param name="msg"></param> private static void Bid(BidRespMsg msg) { try { //检查请求处理结果 if (msg.CheckResult()) { //检查签名 if (msg.CheckSignature()) { #if !DEBUG //同步返回平台不做处理 if (msg.Result.Equals("00001")) return; #endif //查找是否使用了加息券 var context = new Agp2pDataContext(); /*TransactionFacade.Invest((int)msg.UserIdIdentity, msg.ProjectCode, Utils.StrToDecimal(msg.Sum, 0), msg.RequestId, Convert.ToInt32(ticketId));*/ var ticketId = context.li_jiaxiquan_transaction.SingleOrDefault(m => m.requestId == msg.RequestId && m.userId == msg.UserIdIdentity).remarks; //查找对应的交易流水 var trans = context.li_project_transactions.SingleOrDefault(u => u.no_order == msg.RequestId); if (trans != null) { if (trans.status == (int) Agp2pEnums.ProjectTransactionStatusEnum.Pending) { context.ConfirmProjectTransaction(trans.id, Convert.ToInt32(ticketId)); //TODO 检查用户资金信息 msg.HasHandle = true; } } else { msg.Remarks = "没有找到平台交易流水记录,交易流水号为:" + msg.RequestId; } } } } catch (Exception ex) { msg.Remarks = "内部错误:" + ex.Message; } }
/// <summary> /// 处理托管接口请求响应 /// </summary> /// <param name="isSync">是否同步返回</param> protected void DoResponse(bool isSync = false) { Agp2pDataContext context = new Agp2pDataContext(); try { string reqStr = ReadReqStr(); ResponseLog = new li_pay_response_log() { request_id = string.IsNullOrEmpty(Request["requestId"]) ? null : Request["requestId"], result = string.IsNullOrEmpty(Request["result"]) ? "" : Request["result"], status = (int)Agp2pEnums.SumapayResponseEnum.Return, response_time = DateTime.Now, response_content = reqStr }; if (!string.IsNullOrEmpty(ResponseLog.request_id)) { //根据响应报文找到对应的request,生成处理消息,对应各种消息处理逻辑 RequestLog = context.li_pay_request_log.SingleOrDefault(r => r.id == ResponseLog.request_id); if (RequestLog != null) { //检查请求是否已经处理过 if (RequestLog.status != (int)Agp2pEnums.SumapayRequestEnum.Complete) { BaseRespMsg respMsg = null; switch (RequestLog.api) { //个人/企业 开户/激活 case (int)Agp2pEnums.SumapayApiEnum.URegi: case (int)Agp2pEnums.SumapayApiEnum.URegM: case (int)Agp2pEnums.SumapayApiEnum.Activ: case (int)Agp2pEnums.SumapayApiEnum.CRegi: respMsg = new UserRegisterRespMsg(reqStr); break; //个人自动投标续约 case (int)Agp2pEnums.SumapayApiEnum.AtBid: respMsg = new AutoBidSignRespMsg(reqStr); break; //个人自动投标取消 case (int)Agp2pEnums.SumapayApiEnum.ClBid: respMsg = new AutoBidSignRespMsg(reqStr, true); break; //个人/企业 自动账户/银行还款开通 case (int)Agp2pEnums.SumapayApiEnum.AcReO: case (int)Agp2pEnums.SumapayApiEnum.CcReO: case (int)Agp2pEnums.SumapayApiEnum.AbReO: respMsg = new AutoRepaySignRespMsg(reqStr); break; //个人/企业 自动还款取消 case (int)Agp2pEnums.SumapayApiEnum.ClRep: case (int)Agp2pEnums.SumapayApiEnum.CancR: respMsg = new AutoRepaySignRespMsg(reqStr, true); break; //企业/个人网银充值 case (int)Agp2pEnums.SumapayApiEnum.WeRec: case (int)Agp2pEnums.SumapayApiEnum.CeRec: respMsg = new RechargeRespMsg(reqStr); break; //个人一键充值 case (int)Agp2pEnums.SumapayApiEnum.WhRec: case (int)Agp2pEnums.SumapayApiEnum.WhReM: respMsg = new WithholdingRechargeRespMsg(reqStr); break; //个人投标/自动投标 普通/集合项目 case (int)Agp2pEnums.SumapayApiEnum.MaBid: case (int)Agp2pEnums.SumapayApiEnum.McBid: case (int)Agp2pEnums.SumapayApiEnum.MaBiM: case (int)Agp2pEnums.SumapayApiEnum.McBiM: case (int)Agp2pEnums.SumapayApiEnum.AmBid: case (int)Agp2pEnums.SumapayApiEnum.AcBid: respMsg = new BidRespMsg(reqStr); break; //个人撤标 case (int)Agp2pEnums.SumapayApiEnum.CaPro: case (int)Agp2pEnums.SumapayApiEnum.CoPro: respMsg = new WithDrawalRespMsg(reqStr); break; //流标普通项目 case (int)Agp2pEnums.SumapayApiEnum.RePro: respMsg = new RepealProjectRespMsg(reqStr); break; //普通/集合项目放款 case (int)Agp2pEnums.SumapayApiEnum.ALoan: case (int)Agp2pEnums.SumapayApiEnum.CLoan: respMsg = new MakeLoanRespMsg(reqStr); break; //个人/企业提现 case (int)Agp2pEnums.SumapayApiEnum.Wdraw: case (int)Agp2pEnums.SumapayApiEnum.Cdraw: case (int)Agp2pEnums.SumapayApiEnum.WdraM: respMsg = new WithdrawRespMsg(reqStr, isSync); break; //个人/企业 存管账户还款普通/集合项目 case (int)Agp2pEnums.SumapayApiEnum.MaRep: case (int)Agp2pEnums.SumapayApiEnum.McRep: case (int)Agp2pEnums.SumapayApiEnum.CaRep: case (int)Agp2pEnums.SumapayApiEnum.CoRep: respMsg = new RepayRespMsg(reqStr); break; //个人协议还款普通/集合项目 case (int)Agp2pEnums.SumapayApiEnum.BaRep: case (int)Agp2pEnums.SumapayApiEnum.BcRep: respMsg = new RepayRespMsg(reqStr, true); break; //个人自动还款普通/集合项目 case (int)Agp2pEnums.SumapayApiEnum.AcRep: case (int)Agp2pEnums.SumapayApiEnum.AbRep: case (int)Agp2pEnums.SumapayApiEnum.CcRep: case (int)Agp2pEnums.SumapayApiEnum.CbRep: respMsg = new RepayRespMsg(reqStr, false, true); break; //普通/集合项目本息到账 case (int)Agp2pEnums.SumapayApiEnum.RetPt: case (int)Agp2pEnums.SumapayApiEnum.RetCo: respMsg = new ReturnPrinInteRespMsg(reqStr); break; //债权转让 case (int)Agp2pEnums.SumapayApiEnum.CreAs: case (int)Agp2pEnums.SumapayApiEnum.CreAM: respMsg = new CreditAssignmentRespMsg(reqStr); break; //查询项目 case (int)Agp2pEnums.SumapayApiEnum.QuPro: respMsg = BaseRespMsg.NewInstance <QueryProjectRespMsg>(reqStr); break; //银行卡解绑 case (int)Agp2pEnums.SumapayApiEnum.RemCa: respMsg = new RemoveCardRespMsg(reqStr); break; //红包付款至用户 case (int)Agp2pEnums.SumapayApiEnum.HbPay: respMsg = new HongbaoPayRespMsg(reqStr); break; default: respMsg = new BaseRespMsg(); break; } //发送响应消息处理 MessageBus.Main.Publish(respMsg); //更新日志信息 ResponseLog.user_id = respMsg.UserIdIdentity; ResponseLog.project_id = respMsg.ProjectCode; RequestLog.complete_time = DateTime.Now; if (respMsg.HasHandle) { ResponseLog.status = (int)Agp2pEnums.SumapayResponseEnum.Complete; RequestLog.status = (int)Agp2pEnums.SumapayRequestEnum.Complete; } else { ResponseLog.status = (int)Agp2pEnums.SumapayResponseEnum.Invalid; RequestLog.status = (int)Agp2pEnums.SumapayRequestEnum.Fail; //记录失败信息 ResponseLog.remarks += respMsg.Remarks; } context.li_pay_response_log.InsertOnSubmit(ResponseLog); } } else { context.AppendAdminLog("SumaPayNotic", "没有找到对应的请求,RequestID:" + ResponseLog.request_id); } } else { context.AppendAdminLog("SumaPayNotic", "请求流水号为空!返回报文为:" + reqStr); } } catch (Exception ex) { context.AppendAdminLog("SumaPayNotic", "noticeUrl 内部错误:" + ex.Message); } //解决错误“找不到行或已修改” try { context.SubmitChanges(System.Data.Linq.ConflictMode.ContinueOnConflict); } catch (System.Data.Linq.ChangeConflictException ex) { //不再提交数据更新 new Agp2pDataContext().AppendAdminLogAndSave("SumaPayNotic", "noticeUrl 找不到行或已修改:" + ex.Message); } }