Ejemplo n.º 1
0
        /// <summary>
        /// 创建生产退款订单
        /// </summary>
        /// <param name="reqModel"></param>
        /// <returns></returns>
        public override QctPayReturn Build(RefundApplyRequest reqModel)
        {
            WithReqModel(reqModel);
            WithOutTradeNo(reqModel.Out_Refund_No);
            var canObj = CanBuilder();

            if (!canObj.Successed)
            {
                return(canObj);
            }
            else
            {
                ReqModel.ResetRfdNotifyUrl(MerchModel.RfdNotifyUrl);
                var tradeOrder = new TradeOrder(ReqModel, MerchStoreModel)
                {
                    TradeNo       = OrderHelper.GetMaxTradeNo(),
                    OutTradeNo    = ReqModel.Out_Refund_No,
                    OldOutTradeNo = ReqModel.Out_Trade_No,
                    TotalAmount   = ReqModel.Refund_Amount,
                    SourceType    = MerchModel.SourceType,
                    ApiNo         = MerchModel.ApiNo,
                    State         = (short)RefundState.RefundIng,
                    RfdNotifyUrl  = ReqModel.Refund_Notify_Url,
                    OrderType3    = ((short)SxfOrderType.CommonOrder),
                    TradeType     = (short)QctTradeType.Expense,
                    FeeType       = (short)PayFeeType.RMB,
                    BuyerMobile   = ""
                };
                var result = PaySvc.SaveTradeOrder(tradeOrder);
                if (result)
                {
                    //构建Sxf请求参数,签名,发起请求
                    var sxfReqModel = new SxfRefundApplyRequest(tradeOrder, PayConfig.SxfRefundNotifyUrl);
                    var rstObj      = SendPost <SxfRefundApplyRequest, SxfRefundApplyResponse>(MerchStoreModel.ApiUrl, sxfReqModel);
                    if (rstObj.Successed)
                    {
                        //处理返回成功结果,保存退款结果,后进行Qct签名并返回结果回发给商户,fishtodo:暂忽略验证Sxf返回的响应结果签名
                        var sxfRspModel = (SxfRefundApplyResponse)rstObj.Data;
                        //保存退款结果
                        var rfdApplyRsp = new RefundApplyResponse(tradeOrder, sxfRspModel)
                        {
                            Out_Trade_No = sxfReqModel.OldOutTradeNo
                        };
                        return(QctPayReturn.Success(data: PaySignHelper.ToDicAndSign(rfdApplyRsp, MerchModel.SecretKey, "sign")));
                    }
                    else
                    {
                        return(rstObj);
                    }
                }
                else
                {
                    return(ResultFail(msg: "订单提交失败", logMsg: string.Format("退款请求失败:{0},异常信息:{1}", reqModel.ToJson(), tradeOrder.ToJson())));
                }
            }
        }
        /// <summary>
        /// 创建生成支付订单,商家收款扫码,(对应融合支付:被扫支付)
        /// </summary>
        /// <param name="reqModel"></param>
        /// <returns></returns>
        public override QctPayReturn Build(PayMerchScanRequest reqModel)
        {
            WithReqModel(reqModel);
            WithOutTradeNo(reqModel.Out_Trade_No);
            var canObj = CanBuilder();

            if (!canObj.Successed)
            {
                return(canObj);
            }
            else
            {
                var tradeOrder = new TradeOrder(ReqModel, MerchStoreModel, OrderHelper.GetMaxTradeNo());
                tradeOrder.BuyerPayToken = ReqModel.Buyer_Pay_Token;
                var result = PaySvc.SaveTradeOrder(tradeOrder);
                if (result)
                {
                    //构建Sxf请求参数,签名,发起请求
                    var sxfReqModel = new SxfScanPayRequest(tradeOrder, PayConfig.SxfPayNotifyUrl);
                    var rstObj      = SendPost <SxfScanPayRequest, SxfScanPayResponse>(MerchStoreModel.ApiUrl, sxfReqModel);
                    if (rstObj.Successed)
                    {
                        //处理返回成功结果,保存商家收款扫码结果,后进行Qct签名并返回结果回发给商户,fishtodo:暂忽略验证Sxf返回的响应结果签名
                        var sxfRspModel = (SxfScanPayResponse)rstObj.Data;
                        PaySvc.SaveMerchScanResult(sxfRspModel, out tradeOrder);
                        var merchScanRsp = new PayMerchScanResponse(tradeOrder, sxfRspModel);
                        return(QctPayReturn.Success(data: PaySignHelper.ToDicAndSign(merchScanRsp, MerchModel.SecretKey, "sign")));
                    }
                    else
                    {
                        return(rstObj);
                    }
                }
                else
                {
                    return(ResultFail(msg: "订单提交失败", logMsg: string.Format("商家收款扫码请求失败:{0},异常信息:{1}", reqModel.ToJson(), tradeOrder.ToJson())));
                }
            }
        }
Ejemplo n.º 3
0
 private void OnAskEnqueue(TradeOrder order)
 {
     logger.Info($"ask:{order.ToJson()}");
 }
Ejemplo n.º 4
0
 private void OnBidEnqueue(TradeOrder order)
 {
     logger.Info($"bid:{order.ToJson()}");
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 创建生成支付订单,购买者付款扫码,(对应融合支付:主扫支付动态二维码)
 /// </summary>
 /// <param name="reqModel"></param>
 /// <returns></returns>
 public override QctPayReturn Build(PayBuyerScanDynaRequest reqModel)
 {
     try
     {
         WithReqModel(reqModel);
         WithOutTradeNo(reqModel.Out_Trade_No);
         var canObj = CanBuilder();
         if (!canObj.Successed)
         {
             return(canObj);
         }
         else
         {
             var tradeOrder = new TradeOrder(ReqModel, MerchStoreModel, OrderHelper.GetMaxTradeNo());
             var result     = PaySvc.SaveTradeOrder(tradeOrder);
             if (result)
             {
                 //构建Sxf请求参数,签名,发起请求
                 var sxfBuildReq = new SxfBuildPayTokenRequest(tradeOrder, PayConfig.SxfPayNotifyUrl);
                 sxfBuildReq.OrderType = "1";
                 var rstObj = SendPost <SxfBuildPayTokenRequest, SxfBuildPayTokenResponse>(MerchStoreModel.ApiUrl, sxfBuildReq);
                 if (rstObj.Successed)
                 {
                     //处理返回成功结果,将返回结果进行Qct签名并返回给商户,fishtodo:暂忽略验证Sxf返回的响应结果签名
                     var resultObj = new PayBuyerScanDynaResponse(tradeOrder, (SxfBuildPayTokenResponse)rstObj.Data);
                     WithRspModel(resultObj);
                     return(QctPayReturn.Success(data: PaySignHelper.ToDicAndSign(resultObj, MerchModel.SecretKey, "sign")));
                 }
                 return(rstObj);
             }
             else
             {
                 return(ResultFail(msg: "订单提交失败", logMsg: string.Format("购买者付款扫码请求失败:{0},异常信息:{1}", ReqModel.ToJson(), tradeOrder.ToJson())));
             }
         }
     }
     catch (Exception ex)
     {
         return(ResultFail(msg: "订单提交失败", logMsg: string.Format("购买者付款扫码请求异常:{0},异常信息:{1}", ex.Message, ReqModel.ToJson())));
     }
 }