Пример #1
0
        /// <summary>
        /// 更新退款结果记录并关联退款请求记录
        /// </summary>
        /// <param name="resultInfo">退款结果记录</param>
        /// <returns></returns>
        public virtual ExecuteResult <RefundRequestInfo> RelateRequestInfo(RefundResultInfo resultInfo)
        {
            var result = new ExecuteResult <RefundRequestInfo>();

            //判断是否存在有效的退款结果记录,如果存在,则当前退款结果记录不执行
            bool exist = RefundResultDAL.ExistValidRefundResult(resultInfo);

            if (exist)
            {
                resultInfo.ExecuteResult = (int)ResultStatus.Failure;
                resultInfo.ResultDesc    = "已存在有效的退款结果记录";
                RefundResultDAL.Update(resultInfo);

                result.Status  = ResultStatus.Failure;
                result.Message = resultInfo.ResultDesc;
                return(result);
            }

            var requestInfo = RefundRequestDAL.GetValidRefundRequest(resultInfo.OrderId, resultInfo.RefundOrderId, (AppEnum.PayType)resultInfo.PayType);

            if (requestInfo != null && requestInfo.SysNo > 0)
            {
                resultInfo.RequestSysNo = requestInfo.SysNo;
            }

            RefundResultDAL.Update(resultInfo);
            result.Status = ResultStatus.Success;
            result.Data   = requestInfo;
            return(result);
        }
Пример #2
0
        /// <summary>
        /// 退款请求执行成功
        /// </summary>
        /// <param name="requestInfo">退款请求记录</param>
        public virtual void ExecuteSuccess(RefundRequestInfo requestInfo)
        {
            //更新退款请求记录的执行结果
            requestInfo.ExecuteResult = (int)ResultStatus.Success;
            requestInfo.Status        = (int)AppEnum.GlobalStatus.Valid;
            RefundRequestDAL.Update(requestInfo);

            //作废重复的退款请求记录
            RefundRequestDAL.InvalidateRepeatRequest(requestInfo);
        }
Пример #3
0
        /// <summary>
        /// 校验退款参数
        /// </summary>
        /// <param name="data">业务数据报文</param>
        /// <param name="payType">支付方式</param>
        /// <param name="requestInfo">退款请求记录</param>
        /// <returns></returns>
        public virtual ExecuteResult <RefundOrderInfo> CheckParamaters(string data, AppEnum.PayType payType, RefundRequestInfo requestInfo)
        {
            var result = this.CheckParamaters(data, payType);

            if (result.Status != ResultStatus.Success)
            {
                requestInfo.ExecuteResult = (int)ResultStatus.Failure;
                requestInfo.ResultDesc    = result.Message;
                RefundRequestDAL.Update(requestInfo);
            }
            return(result);
        }
Пример #4
0
        /// <summary>
        /// 校验数据签名
        /// </summary>
        /// <param name="appId">业务系统ID</param>
        /// <param name="sign">数据签名</param>
        /// <param name="data">业务数据报文</param>
        /// <param name="requestInfo">退款请求记录</param>
        /// <returns></returns>
        public virtual ExecuteResult CheckSign(string appId, string sign, string data, RefundRequestInfo requestInfo)
        {
            var result = SignManager.CheckSign(appId, sign, data);

            if (result.Status != ResultStatus.Success || !result.Data)
            {
                requestInfo.ExecuteResult = (int)ResultStatus.Failure;
                requestInfo.ResultDesc    = string.IsNullOrWhiteSpace(result.Message) ? "签名校验未通过" : result.Message;
                RefundRequestDAL.Update(requestInfo);
                result.Status = ResultStatus.Failure;
            }
            return(result);
        }
Пример #5
0
        /// <summary>
        /// 保存退款请求
        /// </summary>
        /// <param name="appId">业务系统ID</param>
        /// <param name="data">业务数据报文</param>
        /// <param name="payType">支付方式</param>
        /// <returns></returns>
        public virtual RefundRequestInfo SaveRequest(string appId, string data, AppEnum.PayType payType)
        {
            var requestInfo = new RefundRequestInfo()
            {
                PayType       = (int)payType,
                RequestData   = data,
                ExecuteResult = (int)ResultStatus.None,
                AppId         = appId,
                Status        = (int)AppEnum.GlobalStatus.Valid,
                CreateTime    = DateTime.Now,
            };

            requestInfo.SysNo = RefundRequestDAL.Insert(requestInfo);
            return(requestInfo);
        }
Пример #6
0
        /// <summary>
        /// 解析退款请求
        /// </summary>
        /// <param name="data">业务数据报文</param>
        /// <param name="requestInfo">退款请求记录</param>
        /// <returns></returns>
        public virtual ExecuteResult ResolveRequest(string data, RefundRequestInfo requestInfo)
        {
            var result = new ExecuteResult();
            var info   = JsonHelper.Deserialize <RefundOrderInfo>(data);

            if (info != null)
            {
                requestInfo.OrderId       = info.OrderId;
                requestInfo.TradeNo       = info.TradeNo;
                requestInfo.RefundOrderId = info.RefundOrderId;
                decimal refundAmt = 0;
                decimal.TryParse(info.RefundAmt, out refundAmt);
                requestInfo.RefundAmt = refundAmt;
                requestInfo.NotifyUrl = info.NotifyUrl;
                RefundRequestDAL.Update(requestInfo);
                result.Status = ResultStatus.Success;
            }
            else
            {
                result.Status  = ResultStatus.Failure;
                result.Message = "解析退款请求参数失败";
            }
            return(result);
        }