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
edf0d7d6
Commit
edf0d7d6
authored
Jun 08, 2021
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交代码
parent
83f8b8d6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
12 deletions
+40
-12
RefundsRespModel.cs
Edu.Common/WeChatPayAPIv3.Model/Refunds/RefundsRespModel.cs
+1
-0
WeChatPayController.cs
Edu.WebApi/Controllers/WeChatPay/WeChatPayController.cs
+39
-12
No files found.
Edu.Common/WeChatPayAPIv3.Model/Refunds/RefundsRespModel.cs
View file @
edf0d7d6
...
...
@@ -6,6 +6,7 @@ namespace Edu.Common.WeChatPayAPIv3.Model.Refunds
{
public
class
RefundsRespModel
{
/// <summary>
/// 微信支付退款号。
/// </summary>
...
...
Edu.WebApi/Controllers/WeChatPay/WeChatPayController.cs
View file @
edf0d7d6
...
...
@@ -283,22 +283,39 @@ namespace Edu.WebApi.Controllers.WeChatPay
}
/// <summary>
/// 根据商户订单号查询订单支付信息
/// </summary>
/// <param name="orderNumber"></param>
/// <returns></returns>
[
AllowAnonymous
]
public
async
Task
<
WxPayStatusRespModel
>
QueryOrder
(
string
orderNumber
)
[
AllowRepeatAttribute
]
public
ApiResult
QueryOrder
()
{
JObject
jobj
=
JObject
.
Parse
(
RequestParm
.
Msg
.
ToString
());
string
orderNumber
=
jobj
.
GetStringValue
(
"orderNumber"
);
var
helper
=
new
WxPayHelper
(
WxPayConst
.
appid
,
WxPayConst
.
mchid
,
WxPayConst
.
serialNo
,
WxPayConst
.
privateKey
);
var
payModel
=
await
helper
.
QueryOrder
(
orderNumber
)
;
var
payModel
=
helper
.
QueryOrder
(
orderNumber
).
Result
;
return
payModel
;
return
ApiResult
.
Success
(
data
:
payModel
)
;
}
///// <summary>
///// 根据商户订单号查询订单支付信息
///// </summary>
///// <param name="orderNumber"></param>
///// <returns></returns>
//[AllowAnonymous]
//public async Task<WxPayStatusRespModel> QueryOrder()
//{
// JObject jobj = JObject.Parse(RequestParm.Msg.ToString());
// string orderNumber = jobj.GetStringValue("orderNumber");
// var helper = new WxPayHelper(WxPayConst.appid, WxPayConst.mchid, WxPayConst.serialNo, WxPayConst.privateKey);
// var payModel = await helper.QueryOrder(orderNumber);
// return payModel;
//}
/// <summary>
...
...
@@ -308,22 +325,32 @@ namespace Edu.WebApi.Controllers.WeChatPay
/// <returns></returns>
[
HttpPost
]
[
AllowAnonymous
]
public
async
Task
<
RefundsRespModel
>
Refunds
(
string
orderNumber
)
public
ApiResult
Refunds
(
)
{
JObject
jobj
=
JObject
.
Parse
(
RequestParm
.
Msg
.
ToString
());
int
contractId
=
jobj
.
GetInt
(
"contractId"
);
int
contractId
=
0
;
//
jobj.GetInt("contractId");
string
outTradeNo
=
jobj
.
GetStringValue
(
"OutTradeNo"
);
decimal
RefundsPrice
=
jobj
.
GetDecimal
(
"RefundsPrice"
);
if
(!
string
.
IsNullOrWhiteSpace
(
outTradeNo
))
{
contractId
=
Convert
.
ToInt32
(
outTradeNo
[
17.
.]);
}
var
orderModle
=
educationContractModule
.
GetEducationContractModule
(
contractId
);
var
orderRecordModel
=
educationContractModule
.
GetOrderRecordList
(
new
RB_Finance_OrderRecord
{
ContractId
=
contractId
,
OutTradeNo
=
outTradeNo
}).
FirstOrDefault
();
if
(
orderRecordModel
==
null
)
{
return
new
RefundsRespModel
();
return
ApiResult
.
Failed
(
"未查询到当前商户订单号对应的支付记录"
);
}
if
(
RefundsPrice
>
orderRecordModel
.
TotalPrice
)
{
return
ApiResult
.
Failed
(
"退款金额不能大于收款金额"
);
}
var
helper
=
new
WxPayHelper
(
WxPayConst
.
appid
,
WxPayConst
.
mchid
,
WxPayConst
.
serialNo
,
WxPayConst
.
privateKey
);
var
refundNumber
=
$"
{
DateTime
.
Now
:
yyyyMMddHHmmssfff
}{
contractId
}
"
;
var
payModel
=
await
helper
.
Refunds
(
orderRecordModel
.
OutTradeNo
,
refundNumber
,
orderModle
.
CourseName
+
"退款"
,
Convert
.
ToInt32
(
orderRecordModel
.
TotalPrice
*
100
),
Convert
.
ToInt32
(
orderRecordModel
.
TotalPrice
*
100
),
Config
.
sTenpayNotifyRefundUrl
);
return
payModel
;
var
payModel
=
helper
.
Refunds
(
orderRecordModel
.
OutTradeNo
,
refundNumber
,
orderModle
.
CourseName
+
"退款"
,
Convert
.
ToInt32
(
RefundsPrice
*
100
),
Convert
.
ToInt32
(
orderRecordModel
.
TotalPrice
*
100
),
Config
.
sTenpayNotifyRefundUrl
).
Result
;
return
ApiResult
.
Success
(
data
:
new
{
Result
=
payModel
,
MCh_Id
=
WxPayConst
.
mchid
});
// return payModel;
}
...
...
@@ -430,7 +457,7 @@ namespace Edu.WebApi.Controllers.WeChatPay
OutTradeNo
=
payModel
.
out_refund_no
,
OrderRecordId
=
payOrderRecordModel
?.
ID
??
0
,
TransactionId
=
payModel
.
refund_id
,
TotalPrice
=
Convert
.
ToDecimal
(
payModel
.
amount
.
payer_
total
)
/
100
,
TotalPrice
=
Convert
.
ToDecimal
(
payModel
.
amount
.
payer_
refund
)
/
100
,
ServiceFee
=
OriginalFee
};
bool
result
=
educationContractModule
.
SetEducationContractFinance
(
model
,
orderRecordModel
);
...
...
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