Ejemplo n.º 1
0
        public async Task <IActionResult> Transfers(WeChatPayTransfersViewModel viewModel)
        {
            var request = new WeChatPayPromotionTransfersRequest
            {
                PartnerTradeNo = viewModel.PartnerTradeNo,
                OpenId         = viewModel.OpenId,
                CheckName      = viewModel.CheckName,
                ReUserName     = viewModel.ReUserName,
                Amount         = viewModel.Amount,
                Desc           = viewModel.Desc,
                SpBillCreateIp = viewModel.SpBillCreateIp
            };
            var response = await _client.ExecuteAsync(request, _optionsAccessor.Value);

            return(Ok(response.Body));
        }
Ejemplo n.º 2
0
        public async Task <Result> Agree(int id)
        {
            var apply = await _withdrawalHistoryRepository.FirstOrDefaultAsync(id);

            if (apply == null)
            {
                return(Result.Fail(ResultCodes.IdInvalid));
            }
            if (apply.Status != WithdrawalStatus.Apply)
            {
                return(Result.Fail(ResultCodes.RequestParamError, "当前申请状态不允许确认"));
            }

            var openId = await _custoemrRepository.Query()
                         .Where(e => e.Id == apply.CustomerId)
                         .Select(e => e.OpenId)
                         .FirstOrDefaultAsync();

            apply.Status  = WithdrawalStatus.Success;
            apply.Message = "提现成功";

            var wxRequest = new WeChatPayPromotionTransfersRequest
            {
                PartnerTradeNo = apply.PartnerTradeNo,
                OpenId         = openId,
                CheckName      = "FORCE_CHECK",//  "NO_CHECK"
                ReUserName     = apply.Name,
                Amount         = apply.Amount,
                Desc           = "提现"
            };
            var response = await _client.ExecuteAsync(wxRequest, _weChatPayOptions);

            if (response.ReturnCode != WeChatPayCode.Success || response.ResultCode != WeChatPayCode.Success)
            {
                apply.Status      = WithdrawalStatus.Failed;
                apply.Message     = "提现异常,请重新申请";
                apply.Description = response.ErrCodeDes;

                await _customerManager.UpdateAssets(apply.CustomerId, 0, apply.Total, -apply.ReservedAmount, "提现失败返回金额");
            }

            await _withdrawalHistoryRepository.UpdateAsync(apply);

            return(Result.Ok());
        }