public HttpResponseMessage WxPayBack() { var stream = Request.Content.ReadAsStringAsync().Result; LoggerFactories.CreateLogger().Write($"WxPay Result: {stream}", TraceEventType.Information); try { var doc = XDocument.Parse(stream); var model = new AuctionPaymentRecordModel(); model.FillEntityWithXml(doc); if (model.attach.Equals("kplx_auction")) { var resultPay = _auctionservice.GetAuctionParticipantByOrderNo(model.out_trade_no); var modelPay = (AuctionCarParticipantModel)resultPay.errmsg; //更新竞价 var upstatus = _auctionservice.UpdateStatusForPay(model.out_trade_no).errcode; if (upstatus != 0) { LoggerFactories.CreateLogger().Write("socket result : 支付定金完成,更新竞价状态出错!", TraceEventType.Information); } SendPost(modelPay.Innerid); } else if (model.attach.Equals("kplx_vip")|| model.attach.Equals("kplx_betavip")) //获取会员ID { var custservice = ServiceLocatorFactory.GetServiceLocator().GetService<ICustomerManagementService>(); var custResult = custservice.CustWeChatPayByorderno(model.out_trade_no); if (custResult.errcode == 0) { var custPayModel = (CustWxPayModel) custResult.errmsg; //更新会员状态 var ucstatus = custservice.CustWxPayVipBack(model.out_trade_no).errcode; if (ucstatus != 0) { LoggerFactories.CreateLogger().Write("socket result : 会员支付完成,更新状态出错!", TraceEventType.Information); } SendPost(custPayModel.Custid); } } else if(model.attach.Equals("kplx_activity_crowd")) //众筹活动支付 { var service = ServiceLocatorFactory.GetServiceLocator().GetService<IActivityManagementService>(); service.DoPay(model.out_trade_no); } else if (model.attach.Equals("kplx_mysterious")) //查看神秘车源支付回调 { var service = ServiceLocatorFactory.GetServiceLocator().GetService<ICarManagementService>(); service.DoPay(model.out_trade_no); } //记录支付结果 var result = _auctionservice.AddPaymentRecord(model); LoggerFactories.CreateLogger().Write($"WxPay Saved Result: {result.errcode}", TraceEventType.Information); return new HttpResponseMessage { Content = new StringContent("SUCCESS") }; } catch (Exception ex) { LoggerFactories.CreateLogger().Write($"WxPay Result Ex: {ex.Message}", TraceEventType.Information); return new HttpResponseMessage { Content = new StringContent("ERROR") }; } }
public HttpResponseMessage TestPayBack() { var stream = Request.Content.ReadAsStringAsync().Result; LoggerFactories.CreateLogger().Write($"WxPay Result: {stream}", TraceEventType.Information); try { var doc = XDocument.Parse(stream); var model = new AuctionPaymentRecordModel(); model.FillEntityWithXml(doc); //var result = _auctionservice.AddPaymentRecord(model); } catch (Exception ex) { LoggerFactories.CreateLogger().Write($"WxPay Result Ex: {ex.Message}", TraceEventType.Information); } //调用nodejs 通知前端 return new HttpResponseMessage { Content = new StringContent("") }; }
/// <summary> /// 处理微信支付结果信息 /// </summary> /// <param name="xml">结果信息</param> /// <returns></returns> public static void HandlePayMessage(string xml) { var doc = XDocument.Parse(xml); var model = new AuctionPaymentRecordModel(); model.FillEntityWithXml(doc); //待实现 }
/// <summary> /// 添加定金拍卖定金支付记录 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddPaymentRecord(AuctionPaymentRecordModel model) { const string sql = @"INSERT INTO `auction_paymentrecord` (innerid, appid, attach, bank_type, cash_fee, fee_type, is_subscribe, mch_id, nonce_str, openid, out_trade_no, result_code, return_code, sign, time_end, total_fee, trade_type, transaction_id, createdtime) VALUES (uuid(), @appid, @attach, @bank_type, @cash_fee, @fee_type, @is_subscribe, @mch_id, @nonce_str, @openid, @out_trade_no, @result_code, @return_code, @sign, @time_end, @total_fee, @trade_type, @transaction_id, now());"; using (var conn = Helper.GetConnection()) { int result; var tran = conn.BeginTransaction(); try { result = conn.Execute(sql, model, tran); //更新竞拍人处理状态 //var u = "update auction_participant set `status`=3,remark=CONCAT(remark,@remark) where orderno=@orderno;"; //conn.Execute(u, new { orderno = model.out_trade_no, remark = "\n@通知支付完成" }, tran); tran.Commit(); } catch (Exception ex) { tran.Rollback(); LoggerFactories.CreateLogger().Write("添加定金拍卖定金支付记录异常:", TraceEventType.Error, ex); result = 0; } return result; } }