From 4c41a5d6ca854fb8a58d63038e183c0cdb24d810 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=A8=8B=E6=B3=B0=20=E5=AD=99?= <2608565263@qq.com>
Date: Mon, 10 Oct 2022 15:48:34 +0800
Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=E4=BF=AE?=
=?UTF-8?q?=E5=A4=8D=E5=90=8E=E5=8F=B0=E7=AE=A1=E7=90=86=E8=B4=A6=E6=88=B7?=
=?UTF-8?q?=E4=BD=99=E9=A2=9D=E5=B0=8F=E4=BA=8E=E9=9C=80=E8=A6=81=E6=94=AF?=
=?UTF-8?q?=E4=BB=98=E7=9A=84=E8=AE=A2=E5=8D=95=E9=87=91=E9=A2=9D=E4=BD=86?=
=?UTF-8?q?=E6=98=AF=E6=94=AF=E4=BB=98=E5=90=8E=E6=98=BE=E7=A4=BA=E6=94=AF?=
=?UTF-8?q?=E4=BB=98=E6=88=90=E5=8A=9F=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CoreCms.Net.IRepository/IBaseRepository.cs | 2 +-
.../Bill/CoreCmsBillPaymentsServices.cs | 15 ++++++++----
.../Order/CoreCmsOrderServices.cs | 22 ++++++++++++++++--
CoreShop - 快捷方式.lnk | Bin 0 -> 883 bytes
4 files changed, 32 insertions(+), 7 deletions(-)
create mode 100644 CoreShop - 快捷方式.lnk
diff --git a/CoreCms.Net.IRepository/IBaseRepository.cs b/CoreCms.Net.IRepository/IBaseRepository.cs
index 53eccce..44a6957 100644
--- a/CoreCms.Net.IRepository/IBaseRepository.cs
+++ b/CoreCms.Net.IRepository/IBaseRepository.cs
@@ -32,7 +32,7 @@ namespace CoreCms.Net.IRepository
T QueryById(object pkValue, bool blUseNoLock = false);
///
- /// 根据主值查询单条数据
+ /// 根据主值查询单条数据1
///
///
/// 是否使用WITH(NOLOCK)
diff --git a/CoreCms.Net.Services/Bill/CoreCmsBillPaymentsServices.cs b/CoreCms.Net.Services/Bill/CoreCmsBillPaymentsServices.cs
index d9b9451..1ffb475 100644
--- a/CoreCms.Net.Services/Bill/CoreCmsBillPaymentsServices.cs
+++ b/CoreCms.Net.Services/Bill/CoreCmsBillPaymentsServices.cs
@@ -627,7 +627,7 @@ namespace CoreCms.Net.Services
var orderServices = container.ServiceProvider.GetService();
var jm = new WebApiCallBack();
-
+
var billPaymentInfo = await _dal.QueryByClauseAsync(p =>
p.paymentId == paymentId && p.money == money &&
p.status != (int)GlobalEnumVars.BillPaymentsStatus.Payed);
@@ -643,14 +643,15 @@ namespace CoreCms.Net.Services
billPaymentInfo.payedMsg = payedMsg;
billPaymentInfo.tradeNo = tradeNo;
billPaymentInfo.updateTime = DateTime.Now;
-
+
await _dal.UpdateAsync(billPaymentInfo);
if (status == (int)GlobalEnumVars.BillPaymentsStatus.Payed)
{
if (billPaymentInfo.type == (int)GlobalEnumVars.BillPaymentsType.Order)
{
//如果是订单类型,做支付后处理
- await orderServices.Pay(billPaymentInfo.sourceId, paymentCode, billPaymentInfo);
+ jm= await orderServices.Pay(billPaymentInfo.sourceId, paymentCode, billPaymentInfo);
+
}
else if (billPaymentInfo.type == (int)GlobalEnumVars.BillPaymentsType.Recharge)
{
@@ -674,6 +675,11 @@ namespace CoreCms.Net.Services
//::todo 其他业务逻辑
}
}
+
+ if (jm.status == false)
+ {
+ return jm;
+ }
jm.status = true;
jm.data = paymentId;
jm.msg = "支付成功";
@@ -766,7 +772,8 @@ namespace CoreCms.Net.Services
///
public async Task ToPay(string orderId, int type, string paymentCode)
{
- using (var container = _serviceProvider.CreateScope())
+ using (
+ var container = _serviceProvider.CreateScope())
{
var orderServices = container.ServiceProvider.GetService();
diff --git a/CoreCms.Net.Services/Order/CoreCmsOrderServices.cs b/CoreCms.Net.Services/Order/CoreCmsOrderServices.cs
index 1a960ac..95a6457 100644
--- a/CoreCms.Net.Services/Order/CoreCmsOrderServices.cs
+++ b/CoreCms.Net.Services/Order/CoreCmsOrderServices.cs
@@ -45,6 +45,7 @@ namespace CoreCms.Net.Services
public class CoreCmsOrderServices : BaseServices, ICoreCmsOrderServices
{
private readonly ICoreCmsOrderRepository _dal;
+ private readonly ICoreCmsUserRepository _Userdal;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ICoreCmsShipServices _shipServices;
@@ -100,11 +101,11 @@ namespace CoreCms.Net.Services
, ICoreCmsPaymentsServices paymentsServices
, ICoreCmsBillRefundServices billRefundServices
, ICoreCmsBillLadingServices billLadingServices
- , ICoreCmsBillReshipServices billReshipServices, ICoreCmsMessageCenterServices messageCenterServices, ICoreCmsGoodsCommentServices goodsCommentServices, ISysTaskLogServices taskLogServices, ICoreCmsPromotionRecordServices promotionRecordServices, IRedisOperationRepository redisOperationRepository)
+ , ICoreCmsBillReshipServices billReshipServices, ICoreCmsMessageCenterServices messageCenterServices, ICoreCmsGoodsCommentServices goodsCommentServices, ISysTaskLogServices taskLogServices, ICoreCmsPromotionRecordServices promotionRecordServices, IRedisOperationRepository redisOperationRepository, ICoreCmsUserRepository Userdal)
{
this._dal = dal;
base.BaseDal = dal;
-
+ this._Userdal = Userdal;
_httpContextAccessor = httpContextAccessor;
_shipServices = shipServices;
_cartServices = cartServices;
@@ -1311,6 +1312,18 @@ namespace CoreCms.Net.Services
//获取订单
var order = await _dal.QueryByClauseAsync(p => p.orderId == orderId && p.status == (int)GlobalEnumVars.OrderStatus.Normal);
+ //获取余额
+ var balanceMoney = await _Userdal.QueryByIdAsync(order.userId);
+
+ //若余额小于待付款金额
+ if (order.goodsAmount > balanceMoney.balance)
+ {
+ jm.msg = "余额不足订单支付失败";
+ jm.status = false;
+
+ return jm;
+ }
+
if (order == null)
{
return jm;
@@ -1345,6 +1358,11 @@ namespace CoreCms.Net.Services
order.payStatus = (int)GlobalEnumVars.OrderPayStatus.Yes;
jm.status = true;
jm.msg = "订单支付成功";
+ var newMoney = balanceMoney.balance - order.goodsAmount;
+ //支付成功后
+ //更改余额信息
+ var up = await _Userdal.UpdateAsync(p => new CoreCmsUser() { balance = newMoney }, p => p.id == order.userId);
+
//发票存储
if (order.taxType != (int)GlobalEnumVars.OrderTaxType.No)
diff --git a/CoreShop - 快捷方式.lnk b/CoreShop - 快捷方式.lnk
new file mode 100644
index 0000000000000000000000000000000000000000..5b3517f4c18423248e696d757ca942ca271f4b0c
GIT binary patch
literal 883
zcmeZaU|?VrVFHp23u1O<^*S50(VV
zGeXqE$?psz4DtaF{4XfHvdR=#bc2II+rVJ1B!j-IRSaAaf|18y3g(!GHaQ6}I5Xrk
z6fvYS1T$m+Sp^IX@e}eqiWnF?7&sYN7~bzQ4b69Q4_)D-2h?Mj3DU?6){P);uAPa~
z6g7q@21Bq?)6i8Q+wzN2gER7h);PhdKZ4&){5;F?tLM
z5N!)0fHVlCq!wqFnMpj$Z^7#0Kq%{B}U2!3m@_m(q5r~C3B7lfA-rzwG=CIw`%JP->4G4}XT
zV9;Q2Ww2t<1StiB79a^S(BPx$_V?~m0!u$KCG^aDy+#!%&IM8dG7xAprhz~)Q6T0A
zVg?5gF)95sDEUbOnc%np=>##_Q@{CHMnY8c0r_Cn@Wct^#{x0P4a>5UHEgF|65M)?
z;eh{5i3^TEaXBCcy8#q&Ag9M*x&)l`u!w`SGFSpJ$ncF~xh`va3p|#4IOr|0t>}>j
Xif4cncmT2Z7E=%f1P)msi;w{TfcLsI
literal 0
HcmV?d00001