Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Education
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
Education
Commits
f99ccbc4
Commit
f99ccbc4
authored
May 14, 2021
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交支付回调修改
parent
341670f7
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
274 additions
and
169 deletions
+274
-169
CacheKey.cs
Edu.Cache/CacheKey.cs
+6
-0
UserReidsCache.cs
Edu.Cache/User/UserReidsCache.cs
+22
-2
RB_Order_Guest.cs
Edu.Model/Entity/Course/RB_Order_Guest.cs
+5
-0
ClassModule.cs
Edu.Module.Course/ClassModule.cs
+1
-1
OrderModule.cs
Edu.Module.Course/OrderModule.cs
+24
-3
ClassController.cs
Edu.WebApi/Controllers/Course/ClassController.cs
+17
-0
OrderController.cs
Edu.WebApi/Controllers/Course/OrderController.cs
+3
-1
WeChatPayController.cs
Edu.WebApi/Controllers/WeChatPay/WeChatPayController.cs
+196
-162
No files found.
Edu.Cache/CacheKey.cs
View file @
f99ccbc4
...
...
@@ -37,5 +37,11 @@ namespace Edu.Cache
/// </summary>
public
static
string
Student_Frozen_Key
=
"Edu_Student_Frozen_"
;
/// <summary>
/// 微信支付回调key
/// </summary>
public
static
string
WeChatPay_Callback_Key
=
"WeChatPay_Callback_Key_"
;
}
}
Edu.Cache/User/UserReidsCache.cs
View file @
f99ccbc4
...
...
@@ -71,12 +71,32 @@ namespace Edu.Cache.User
{
TimeSpan
ts
=
GetExpirTime
(
JwtExpirTime
);
redis
.
StringSet
(
cacheKey
,
Data
,
ts
);
}
catch
(
Exception
)
{
}
}
/// <summary>
/// 获取缓存
/// </summary>
/// <param name="cacheKey"></param>
/// <param name="Data"></param>
/// <param name="JwtExpirTime"></param>
public
static
object
Get
(
string
cacheKey
,
object
Data
,
int
JwtExpirTime
)
{
try
{
object
info
=
redis
.
StringGet
<
object
>(
cacheKey
);
return
info
;
}
catch
(
Exception
)
{
return
""
;
}
}
/// <summary>
/// 账号仓储层对象
/// </summary>
...
...
@@ -88,7 +108,7 @@ namespace Edu.Cache.User
/// <param name="Id">账号Id</param>
/// <param name="apiRequestFromEnum">请求来源</param>
/// <returns></returns>
public
static
UserInfo
GetUserLoginInfo
(
object
Id
,
ApiRequestFromEnum
apiRequestFromEnum
=
ApiRequestFromEnum
.
WebAdmin
)
public
static
UserInfo
GetUserLoginInfo
(
object
Id
,
ApiRequestFromEnum
apiRequestFromEnum
=
ApiRequestFromEnum
.
WebAdmin
)
{
UserInfo
userInfo
=
null
;
if
(
Id
!=
null
)
...
...
Edu.Model/Entity/Course/RB_Order_Guest.cs
View file @
f99ccbc4
...
...
@@ -190,5 +190,10 @@ namespace Edu.Model.Entity.Course
/// 补课课时
/// </summary>
public
int
MakeUpHours
{
get
;
set
;
}
/// <summary>
/// 学生头像
/// </summary>
public
string
StuIcon
{
get
;
set
;
}
}
}
Edu.Module.Course/ClassModule.cs
View file @
f99ccbc4
...
...
@@ -963,7 +963,7 @@ namespace Edu.Module.Course
{
list
.
Add
(
new
{
UserIcon
=
""
,
UserIcon
=
item
.
StuIcon
,
item
.
Id
,
SexStr
=
item
.
Sex
==
1
?
"男"
:
"女"
,
item
.
GuestName
,
...
...
Edu.Module.Course/OrderModule.cs
View file @
f99ccbc4
...
...
@@ -1525,6 +1525,13 @@ namespace Edu.Module.Course
{
LogContent
+=
",总课时由【"
+
gModel
.
TotalHours
+
"】修改为【"
+
dmodel
.
TotalHours
+
"】"
;
}
if
(
gModel
.
StuIcon
!=
dmodel
.
StuIcon
)
{
LogContent
+=
",学生头像由【"
+
gModel
.
StuIcon
+
"】修改为【"
+
dmodel
.
StuIcon
+
"】"
;
}
gModel
.
StuIcon
=
dmodel
.
StuIcon
;
gModel
.
TotalHours
=
dmodel
.
TotalHours
;
gModel
.
UpdateTime
=
dmodel
.
UpdateTime
;
...
...
@@ -1543,6 +1550,19 @@ namespace Edu.Module.Course
School_Id
=
dmodel
.
School_Id
,
SourceId
=
gModel
.
OrderId
});
if
(!
string
.
IsNullOrWhiteSpace
(
dmodel
.
StuIcon
))
//更新学生表中的头像
{
var
orderGuestModel
=
student_OrderGuestRepository
.
GetStrOrderGuestListRepository
(
new
RB_Student_OrderGuest_ViewModel
{
ClassId
=
gModel
.
ClassId
,
OrderId
=
gModel
.
OrderId
,
GuestId
=
gModel
.
Id
}).
FirstOrDefault
();
if
(
orderGuestModel
!=
null
&&
orderGuestModel
.
Student_Id
>
0
)
{
Dictionary
<
string
,
object
>
fileds
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Student_ViewModel
.
StuIcon
),
dmodel
.
StuIcon
},
};
studentRepository
.
Update
(
fileds
,
new
WhereHelper
(
nameof
(
RB_Student_ViewModel
.
StuId
),
orderGuestModel
.
Student_Id
));
}
}
}
}
else
...
...
@@ -1603,12 +1623,13 @@ namespace Edu.Module.Course
School_Id
=
classmodel
.
School_Id
,
Status
=
DateStateEnum
.
Normal
,
StuBirth
=
dmodel
.
BirthDate
,
StuIcon
=
""
,
StuIcon
=
dmodel
.
StuIcon
,
StuName
=
dmodel
.
GuestName
,
StuSex
=
dmodel
.
Sex
-
1
,
StuTel
=
dmodel
.
Mobile
,
UpdateBy
=
dmodel
.
CreateBy
,
UpdateTime
=
DateTime
.
Now
UpdateTime
=
DateTime
.
Now
,
});
int
AccountId
=
accountRepository
.
Insert
(
new
Model
.
Entity
.
User
.
RB_Account
()
{
...
...
@@ -1650,7 +1671,7 @@ namespace Edu.Module.Course
Group_Id
=
dmodel
.
Group_Id
,
LogContent
=
LogContent
,
School_Id
=
dmodel
.
School_Id
,
SourceId
=
dmodel
.
OrderId
SourceId
=
dmodel
.
OrderId
,
});
}
}
...
...
Edu.WebApi/Controllers/Course/ClassController.cs
View file @
f99ccbc4
...
...
@@ -1435,6 +1435,23 @@ namespace Edu.WebApi.Controllers.Course
bool
retult
=
classModule
.
UpdateTimeClassVideo
(
extModel
.
VideoUrl
,
extModel
.
ClassTimeId
);
return
retult
?
ApiResult
.
Success
(
"课堂视频更新成功"
)
:
ApiResult
.
Failed
(
"课堂视频更新失败"
);
}
/// <summary>
/// 获取学员列表
/// </summary>
/// <returns></returns>
[
HttpPost
]
[
Microsoft
.
AspNetCore
.
Authorization
.
AllowAnonymous
]
public
ApiResult
GetStudentByClassId
()
{
var
classId
=
base
.
ParmJObj
.
GetInt
(
"ClassId"
);
var
schoolId
=
0
;
var
Group_Id
=
base
.
ParmJObj
.
GetInt
(
"Group_Id"
,
100000
);
var
data
=
classModule
.
GetClassStudentListModule
(
classId
,
schoolId
,
Group_Id
);
return
ApiResult
.
Success
(
data
:
data
);
}
#
endregion
}
...
...
Edu.WebApi/Controllers/Course/OrderController.cs
View file @
f99ccbc4
...
...
@@ -883,6 +883,7 @@ namespace Edu.WebApi.Controllers.Course
x
.
VolunteerMajor
,
x
.
Price
,
x
.
StudyRemark
,
x
.
StuIcon
});
return
ApiResult
.
Success
(
""
,
pageModel
);
}
...
...
@@ -920,7 +921,8 @@ namespace Edu.WebApi.Controllers.Course
Price
=
base
.
ParmJObj
.
GetDecimal
(
"Price"
),
StudyRemark
=
base
.
ParmJObj
.
GetStringValue
(
"StudyRemark"
),
BirthDate
=
base
.
ParmJObj
.
GetDateTime
(
"BirthDate"
),
TotalHours
=
base
.
ParmJObj
.
GetInt
(
"TotalHours"
)
TotalHours
=
base
.
ParmJObj
.
GetInt
(
"TotalHours"
),
StuIcon
=
base
.
ParmJObj
.
GetStringValue
(
"StuIcon"
),
};
if
(
dmodel
.
OrderId
<=
0
)
{
...
...
Edu.WebApi/Controllers/WeChatPay/WeChatPayController.cs
View file @
f99ccbc4
...
...
@@ -93,10 +93,14 @@ namespace Edu.WebApi.Controllers.WeChatPay
var
resource
=
wxPayNotifyModel
?.
resource
??
new
WxPayResourceModel
();
var
decryptStr
=
AesGcmHelper
.
AesGcmDecrypt
(
resource
.
associated_data
,
resource
.
nonce
,
resource
.
ciphertext
,
WxPayConst
.
APIV3Key
);
LogHelper
.
WriteInfo
(
"订单回调信息decryptStr"
+
decryptStr
);
var
decrypt
Model
=
Common
.
Plugin
.
JsonHelper
.
DeserializeObject
<
WxPayResourceDecryptModel
>(
decryptStr
);
//decryptStr.ToObject<WxPayResourceDecryptModel>();
var
pay
Model
=
Common
.
Plugin
.
JsonHelper
.
DeserializeObject
<
WxPayResourceDecryptModel
>(
decryptStr
);
//decryptStr.ToObject<WxPayResourceDecryptModel>();
if
(
string
.
IsNullOrEmpty
(
decryptModel
.
out_trade_no
))
if
(
payModel
.
trade_state
==
"SUCCESS"
)
{
viewModel
.
code
=
"SUCCESS"
;
viewModel
.
message
=
""
;
}
if
(
string
.
IsNullOrEmpty
(
payModel
.
out_trade_no
))
{
viewModel
.
code
=
"FAIL"
;
viewModel
.
message
=
"数据解密失败"
;
...
...
@@ -104,12 +108,51 @@ namespace Edu.WebApi.Controllers.WeChatPay
}
else
{
var
payModel
=
await
QueryOrder
(
decryptModel
.
out_trade_no
);
if
(
payModel
!=
null
&&
payModel
.
trade_state
==
"SUCCESS"
)
//生成财务单据
{
//然后进行数据库更新处理……等等其他操作
UpdateFinance
(
payModel
);
//生成财务单据以及生成支付记录
viewModel
.
code
=
"SUCCESS"
;
viewModel
.
message
=
""
;
}
}
}
catch
(
Exception
ex
)
{
lock
(
_lock
)
viewModel
.
code
=
"FAIL"
;
viewModel
.
message
=
"数据解密失败"
;
}
return
viewModel
;
}
/// <summary>
/// 生成财务单据以及生成支付记录
/// </summary>
/// <param name="payModel"></param>
/// <returns></returns>
[
AllowAnonymous
]
public
async
Task
UpdateFinance
(
WxPayResourceDecryptModel
payModel
)
{
LogHelper
.
WriteInfo
(
"我是回调"
+
System
.
DateTime
.
Now
);
int
contractId
=
Convert
.
ToInt32
(
payModel
.
out_trade_no
[
17.
.]);
bool
isAdd
=
false
;
if
(!
Cache
.
User
.
UserReidsCache
.
Exists
(
Cache
.
CacheKey
.
WeChatPay_Callback_Key
+
payModel
.
out_trade_no
))
{
LogHelper
.
WriteInfo
(
payModel
.
out_trade_no
+
"我是回调:"
+
System
.
DateTime
.
Now
);
Cache
.
User
.
UserReidsCache
.
Set
(
Cache
.
CacheKey
.
WeChatPay_Callback_Key
+
payModel
.
out_trade_no
,
payModel
.
out_trade_no
,
1800
);
isAdd
=
true
;
Cache
.
User
.
UserReidsCache
.
Set
(
Cache
.
CacheKey
.
WeChatPay_Callback_Key
+
payModel
.
out_trade_no
,
payModel
.
out_trade_no
,
1800
);
var
oldOrderRecordModel
=
educationContractModule
.
GetOrderRecordList
(
new
RB_Finance_OrderRecord
{
ContractId
=
contractId
,
OutTradeNo
=
payModel
.
out_trade_no
}).
FirstOrDefault
();
if
(
oldOrderRecordModel
==
null
||
oldOrderRecordModel
.
ID
==
0
)
{
isAdd
=
true
;
}
if
(
isAdd
)
{
LogHelper
.
WriteInfo
(
payModel
.
out_trade_no
+
"我要新增财务单据啦...."
+
System
.
DateTime
.
Now
);
var
orderModle
=
educationContractModule
.
GetEducationContractModule
(
contractId
);
var
orderModel
=
orderModule
.
GetClassOrderInfo
(
orderModle
.
OrderId
);
var
financeConfig
=
educationContractModule
.
GetFinanceConfigList
(
new
Model
.
ViewModel
.
Course
.
RB_Finance_Config_ViewModel
{
Group_Id
=
orderModle
.
Group_Id
,
Type
=
Common
.
Enum
.
Course
.
FinanceConfigTypeEnum
.
Tuition
}).
FirstOrDefault
();
...
...
@@ -135,7 +178,7 @@ namespace Edu.WebApi.Controllers.WeChatPay
TotalPrice
=
Convert
.
ToDecimal
(
payModel
.
amount
.
payer_total
)
/
100
,
ServiceFee
=
OriginalFee
};
#
region
财务单据数据组装
var
detailList
=
new
List
<
object
>();
detailList
.
Add
(
new
{
...
...
@@ -173,6 +216,8 @@ namespace Edu.WebApi.Controllers.WeChatPay
OrderId
=
orderModle
.
OrderId
,
TCIDList
=
orderModel
.
ClassId
>
0
?
new
List
<
int
>()
{
orderModel
.
ClassId
}
:
new
List
<
int
>(),
};
#
endregion
string
sign
=
EncryptionHelper
.
AesEncrypt
(
JsonHelper
.
Serialize
(
financeObj
),
Config
.
FinanceKey
);
var
resultInfo
=
new
{
...
...
@@ -221,28 +266,19 @@ namespace Edu.WebApi.Controllers.WeChatPay
FinanceId
=
0
,
};
}
bool
result
=
educationContractModule
.
SetEducationContractFinance
(
model
,
orderRecordModel
);
}
viewModel
.
code
=
"SUCCESS"
;
viewModel
.
message
=
"数据接收成功"
;
Cache
.
User
.
UserReidsCache
.
Set
(
Cache
.
CacheKey
.
WeChatPay_Callback_Key
+
payModel
.
out_trade_no
,
payModel
.
out_trade_no
,
1
);
}
//然后进行数据库更新处理……等等其他操作
else
{
LogHelper
.
WriteInfo
(
"存在Key"
+
System
.
DateTime
.
Now
);
}
}
catch
(
Exception
ex
)
{
viewModel
.
code
=
"FAIL"
;
viewModel
.
message
=
"数据解密失败"
;
}
return
viewModel
;
}
[
AllowAnonymous
]
public
async
Task
<
WxPayStatusRespModel
>
QueryOrder
(
string
orderNumber
)
...
...
@@ -292,20 +328,18 @@ namespace Edu.WebApi.Controllers.WeChatPay
//我没有使用官方的那种验证数据安全性的方法,我解密出来数据之后,直接拿着商户退款订单号再去查询一下订单状态,然后再更新到数据库中。我嫌麻烦……
var
resource
=
wxPayNotifyModel
?.
resource
??
new
RefundsCallbackResourceModel
();
var
decryptStr
=
AesGcmHelper
.
AesGcmDecrypt
(
resource
.
associated_data
,
resource
.
nonce
,
resource
.
ciphertext
,
WxPayConst
.
APIV3Key
);
var
decrypt
Model
=
Common
.
Plugin
.
JsonHelper
.
DeserializeObject
<
RefundsCallbackDecryptModel
>(
decryptStr
);
//decryptStr.ToObject<RefundsCallbackDecryptModel>();
var
pay
Model
=
Common
.
Plugin
.
JsonHelper
.
DeserializeObject
<
RefundsCallbackDecryptModel
>(
decryptStr
);
//decryptStr.ToObject<RefundsCallbackDecryptModel>();
var
viewModel
=
new
RefundsCallbackRespModel
();
if
(
string
.
IsNullOrEmpty
(
decrypt
Model
.
out_trade_no
))
if
(
string
.
IsNullOrEmpty
(
pay
Model
.
out_trade_no
))
{
viewModel
.
code
=
"FAIL"
;
viewModel
.
message
=
"数据解密失败"
;
}
else
{
var
payModel
=
await
QueryRefunds
(
decryptModel
.
out_refund_no
);
if
(
payModel
!=
null
&&
payModel
.
status
==
"SUCCESS"
)
//生成财务单据
{
lock
(
_lock
)
// var payModel = await QueryRefunds(decryptModel.out_refund_no);
if
(
payModel
!=
null
&&
payModel
.
refund_status
==
"SUCCESS"
)
//生成财务单据
{
int
contractId
=
Convert
.
ToInt32
(
payModel
.
out_trade_no
[
17.
.]);
var
orderModle
=
educationContractModule
.
GetEducationContractModule
(
contractId
);
...
...
@@ -332,9 +366,9 @@ namespace Edu.WebApi.Controllers.WeChatPay
ServiceFee
=
OriginalFee
};
bool
result
=
educationContractModule
.
SetEducationContractFinance
(
model
,
orderRecordModel
);
}
viewModel
.
code
=
"SUCCESS"
;
viewModel
.
message
=
"
数据接收成功
"
;
viewModel
.
message
=
""
;
}
//然后进行数据库更新处理……等等其他操作
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment