|
|
@ -198,6 +198,7 @@ namespace GDZZ.Application.Service.WXPay
|
|
|
|
var payTake = await this.payTakeRep.InsertReturnEntityAsync(new MiniPayTake()
|
|
|
|
var payTake = await this.payTakeRep.InsertReturnEntityAsync(new MiniPayTake()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PaymentMoney = authUserInput.Money,
|
|
|
|
PaymentMoney = authUserInput.Money,
|
|
|
|
|
|
|
|
Type = Enum.PayTypeEnum.BUY,
|
|
|
|
OrderId = recharge.Id,
|
|
|
|
OrderId = recharge.Id,
|
|
|
|
PaySn = "",
|
|
|
|
PaySn = "",
|
|
|
|
PayStatus = PayStatusEnum.NotPaying
|
|
|
|
PayStatus = PayStatusEnum.NotPaying
|
|
|
@ -238,6 +239,68 @@ namespace GDZZ.Application.Service.WXPay
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 卡消费支付
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="authUserInput">商品Id</param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
|
|
|
[Route("Mini/v1/wxCardPay")]
|
|
|
|
|
|
|
|
public async Task<dynamic> wxCardPay(AuthUserInput authUserInput)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var payres = await this.payTakeRep.AsQueryable().Where(x => x.Type == Enum.PayTypeEnum.BUY && (DateTime.Now - x.CreatedTime.Value).TotalDays < 30 && x.CreatedUserId == UserManager.UserId).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!payres.IsEmpty())
|
|
|
|
|
|
|
|
return "已经购买";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var payTake = await this.payTakeRep.InsertReturnEntityAsync(new MiniPayTake()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
PaymentMoney = authUserInput.Money,
|
|
|
|
|
|
|
|
OrderId = YitIdHelper.NextId(),
|
|
|
|
|
|
|
|
Type = Enum.PayTypeEnum.BUY,
|
|
|
|
|
|
|
|
PaySn = "",
|
|
|
|
|
|
|
|
PayStatus = PayStatusEnum.NotPaying
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int pMoney = (int)(authUserInput.Money );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string sp_billno =
|
|
|
|
|
|
|
|
$"{Config.SenparcWeixinSetting.TenPayV3_MchId}{SystemTime.Now:yyyyMMddHHmmss}{TenPayV3Util.BuildRandomStr(6)}";
|
|
|
|
|
|
|
|
string timeStamp = TenPayV3Util.GetTimestamp();
|
|
|
|
|
|
|
|
string nonceStr = TenPayV3Util.GetNoncestr();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TenPayV3UnifiedorderRequestData xmlDataInfo = new TenPayV3UnifiedorderRequestData(Config.SenparcWeixinSetting.WxOpenAppId,
|
|
|
|
|
|
|
|
Config.SenparcWeixinSetting.TenPayV3_MchId, "开卡支付", sp_billno,
|
|
|
|
|
|
|
|
pMoney,
|
|
|
|
|
|
|
|
"127.0.0.1",
|
|
|
|
|
|
|
|
Config.SenparcWeixinSetting.TenPayV3_TenpayNotify, TenPayV3Type.JSAPI, authUserInput.OpenID,
|
|
|
|
|
|
|
|
Config.SenparcWeixinSetting.TenPayV3_Key, nonceStr, null, null, null, null, payTake.OrderId.ToString());
|
|
|
|
|
|
|
|
Console.WriteLine(xmlDataInfo.PackageRequestHandler.ParseXML());
|
|
|
|
|
|
|
|
var result = TenPayOldV3.Unifiedorder(xmlDataInfo);//调用统一订单接口
|
|
|
|
|
|
|
|
string packageStr = "prepay_id=" + result.prepay_id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
success = true,
|
|
|
|
|
|
|
|
result.prepay_id,
|
|
|
|
|
|
|
|
appId = Config.SenparcWeixinSetting.WxOpenAppId,
|
|
|
|
|
|
|
|
timeStamp,
|
|
|
|
|
|
|
|
nonceStr,
|
|
|
|
|
|
|
|
package = packageStr,
|
|
|
|
|
|
|
|
signType = "MD5",
|
|
|
|
|
|
|
|
paySign = TenPayV3.GetJsPaySign(Config.SenparcWeixinSetting.WxOpenAppId, timeStamp, nonceStr,
|
|
|
|
|
|
|
|
packageStr, Config.SenparcWeixinSetting.TenPayV3_Key)
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 微信小程序支付回调
|
|
|
|
/// 微信小程序支付回调
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -267,11 +330,17 @@ namespace GDZZ.Application.Service.WXPay
|
|
|
|
var paymentId = long.Parse(resHandler.GetParameter("attach"));
|
|
|
|
var paymentId = long.Parse(resHandler.GetParameter("attach"));
|
|
|
|
//业务处理
|
|
|
|
//业务处理
|
|
|
|
var paytake = await this.payTakeRep.Where(x => x.OrderId == paymentId).SingleAsync();
|
|
|
|
var paytake = await this.payTakeRep.Where(x => x.OrderId == paymentId).SingleAsync();
|
|
|
|
if (!paytake.IsEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
if (paytake.IsEmpty())
|
|
|
|
|
|
|
|
throw Oops.Oh("无此订单,回调失败");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.payTakeRep.BeginTran();
|
|
|
|
paytake.PayStatus = PayStatusEnum.Paying;
|
|
|
|
paytake.PayStatus = PayStatusEnum.Paying;
|
|
|
|
this.payTakeRep.Update(paytake);
|
|
|
|
|
|
|
|
}
|
|
|
|
switch (paytake.Type)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case Enum.PayTypeEnum.RECHARGE:
|
|
|
|
var recharge = await this.rechargeRep.Where(x => x.Id == paymentId).SingleAsync();
|
|
|
|
var recharge = await this.rechargeRep.Where(x => x.Id == paymentId).SingleAsync();
|
|
|
|
if (!recharge.IsEmpty())
|
|
|
|
if (!recharge.IsEmpty())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -292,11 +361,21 @@ namespace GDZZ.Application.Service.WXPay
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Enum.PayTypeEnum.BUY:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
throw Oops.Oh("订单类型错误");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.payTakeRep.Update(paytake);
|
|
|
|
|
|
|
|
|
|
|
|
content.Content = string.Format(@"<xml>
|
|
|
|
content.Content = string.Format(@"<xml>
|
|
|
|
<return_code><![CDATA[{0}]]></return_code>
|
|
|
|
<return_code><![CDATA[{0}]]></return_code>
|
|
|
|
<return_msg><![CDATA[{1}]]></return_msg>
|
|
|
|
<return_msg><![CDATA[{1}]]></return_msg>
|
|
|
|
</xml>", return_code, return_msg);
|
|
|
|
</xml>", return_code, return_msg);
|
|
|
|
this.SendTemplate(0, return_code, resHandler);
|
|
|
|
this.SendTemplate(0, return_code, resHandler);
|
|
|
|
|
|
|
|
this.payTakeRep.CommitTran();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -308,11 +387,14 @@ namespace GDZZ.Application.Service.WXPay
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
this.payTakeRep.RollbackTran();
|
|
|
|
content.Content = ex.Message;
|
|
|
|
content.Content = ex.Message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return content;
|
|
|
|
return content;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|