protected void btnConfirm_Click(object sender, EventArgs e) { WithholdingView poolpayWithholding = AccountService.GetWithholding(WithholdingAccountType.Poolpay, CurrentCompany.CompanyId); if (poolpayWithholding != null && poolpayWithholding.Status == WithholdingProtocolStatus.Success) { try { if (string.IsNullOrEmpty(txtCancelPayPassword.Text.Trim())) { throw new ChinaPay.Core.Exception.InvalidValueException("支付密码不能为空"); } AccountTradeService.CancelPoolPayCAE(poolpayWithholding.AccountNo, txtCancelPayPassword.Text.Trim()); poolpayWithholding.Status = WithholdingProtocolStatus.Submitted; AccountService.CancelWithholdingInfo(poolpayWithholding); BindPoolpayAccountInfo(); ShowMessage("关闭代扣成功"); } catch (Exception ex) { ShowExceptionMessage(ex, "关闭代扣"); } } else { ShowMessage("该账号未设置代扣"); } }
protected void btnPoolpayNo_Click(object sender, EventArgs e) { decimal dcAmount; string amount = txtAmount.Text.Trim(); string poolpayAccountNo = txtPoolpayAccountNo.Text.Trim(); string payPassword = txtPayPassword.Text.Trim(); if (string.IsNullOrEmpty(amount)) { ShowMessage("自动支付最大金额不能为空"); return; } if (!Regex.IsMatch(amount, @"^\d{1,7}(\.\d{1,2})?$")) { ShowMessage("自动支付最大金额格式错误"); return; } if (!decimal.TryParse(amount, out dcAmount)) { ShowMessage("自动支付最大金额格式错误"); return; } if (string.IsNullOrEmpty(poolpayAccountNo)) { ShowMessage("国付通账号不能为空"); return; } if (string.IsNullOrEmpty(payPassword)) { ShowMessage("支付密码不能为空"); return; } PoolPayCAEDTO poolPayCAEDTO = new PoolPayCAEDTO { Amount = dcAmount, PayPassword = payPassword, TransAccountOut = poolpayAccountNo, TransAccountIn = ChinaPay.B3B.Service.SystemManagement.SystemParamService.PlatformSettleAccount }; try { AccountTradeService.BuildPoolPayCAE(poolPayCAEDTO); WithholdingView withholdingView = createWithholding(dcAmount, poolpayAccountNo); AccountService.SetWithholdingInfo(withholdingView); BindPoolpayAccountInfo(); ShowMessage("设置成功"); } catch (Exception ex) { ShowExceptionMessage(ex, "设置"); } }
/// <summary> /// 代扣 /// </summary> /// <param name="tradeView"></param> public static global::PoolPay.DomainModel.Trade.PayTrade AutoPay(AccountTradeDTO tradeView, WithholdingAccountType type) { global::PoolPay.DomainModel.Trade.PayTrade pay = null; string success = ""; if (type == WithholdingAccountType.Poolpay) { pay = AccountTradeService.AccountPay(tradeView, ""); if (pay != null && pay.Status == global::PoolPay.DataTransferObject.PayStatus.PaySuccess) { success = "SUCCESS"; } else { throw new Exception("支付失败!"); } } else if (type == WithholdingAccountType.Alipay) { success = AccountTradeService.InterfacePay(tradeView); } if (success != "") { if (success.ToUpper() == "SUCCESS") { using (var command = Factory.CreateCommand()) { var autoPayRepository = Factory.CreateAutoPayRepository(command); autoPayRepository.UpdateSuccess(decimal.Parse(tradeView.OutOrderId)); } } else { throw new Exception("支付失败!"); } var tradementLog = new Log.Domain.TradementLog { OrderId = decimal.Parse(tradeView.OutOrderId), Request = "订单号:" + tradeView.OutOrderId, Response = success, Time = DateTime.Now, Remark = "修改代扣处理状态", }; LogService.SaveTradementLog(tradementLog); } return(pay); }
/// <summary> /// 查询申请单支付状态,补单 /// </summary> /// <param name="applyformId"></param> /// <returns></returns> public string QueryPaymentInfo(decimal applyformId) { bool paySuccess = false; var applyform = ApplyformQueryService.QueryApplyform(applyformId) as PostponeApplyform; if (applyform == null) { return("改期申请单不存在"); } if (applyform.Status != PostponeApplyformStatus.Agreed) { return("OK"); } try { #if (DEBUG) var tradeResult = AccountTradeService.PayTradeQuery(applyformId.ToString()); if (tradeResult == null) { return("查询支付信息失败"); } if (tradeResult.Status != PayStatus.PaySuccess) { return("没有查询到支付成功信息"); } var paramArray = tradeResult.CustomParameter.Split('|'); if (paramArray.Length >= 3) { var operatorAccount = paramArray[2]; ChinaPay.B3B.DataTransferObject.Common.PayInterface payInterface = ChinaPay.B3B.Service.Tradement.NotifyService.ParsePayInterface(tradeResult.payInterface); ChinaPay.B3B.DataTransferObject.Common.PayAccountType payAccountType = ChinaPay.B3B.Service.Tradement.NotifyService.ParsePayAccountType(tradeResult.payAccountType); ApplyformProcessService.PostponeFeePaySuccess( applyform.Id, tradeResult.AccountNo, tradeResult.TradeNo, tradeResult.FillChargeId.ToString(),//channelTradeNo tradeResult.PayTime.Value, payInterface, payAccountType, operatorAccount); paySuccess = true; } LogService.SaveTradementLog(new TradementLog() { OrderId = applyform.OrderId, ApplyformId = applyformId, Type = TradementBusinessType.SubPay, Request = string.Empty, Response = string.Empty, Remark = "改期支付补单", Time = DateTime.Now }); #else QueryPaymentProcess queryPayment = new QueryPaymentProcess(applyformId.ToString()); if (queryPayment.Execute() && queryPayment.PaySuccess) { var paramArray = queryPayment.ExtraParams.Split('|'); if (paramArray.Length >= 3) { var operatorAccount = paramArray[2]; ApplyformProcessService.PostponeFeePaySuccess( applyform.Id, queryPayment.PayAccount, queryPayment.PayTradeNo, queryPayment.ChannelTradeNo, queryPayment.PayTime, queryPayment.PayChannel, queryPayment.PayAccountType, operatorAccount); paySuccess = true; } LogService.SaveTradementLog(new TradementLog() { OrderId = applyform.OrderId, ApplyformId = applyformId, Type = TradementBusinessType.SubPay, Request = string.Empty, Response = queryPayment.ExtraParams, Remark = "改期支付补单", Time = DateTime.Now }); } else { return("查询支付信息失败"); } #endif } catch (Exception ex) { LogService.SaveExceptionLog(ex, "补单"); paySuccess = false; } return(paySuccess?"OK":"ERROR"); }