Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
shop
Project
Project
Details
Activity
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
曲欣亮
shop
Commits
54ad0368
Commit
54ad0368
authored
Apr 17, 2023
by
张永
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加微企付回调
parent
bfe51b4a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
4 deletions
+99
-4
PayNotifyController.java
src/main/java/com/egolm/shop/api/PayNotifyController.java
+5
-2
OrderService.java
src/main/java/com/egolm/shop/api/service/OrderService.java
+2
-0
OrderServiceImpl.java
...ava/com/egolm/shop/api/service/impl/OrderServiceImpl.java
+92
-2
No files found.
src/main/java/com/egolm/shop/api/PayNotifyController.java
View file @
54ad0368
...
...
@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.alibaba.fastjson.JSONObject
;
import
com.egolm.common.DateUtil
;
import
com.egolm.common.GsonUtil
;
import
com.egolm.common.HttpsUtil
;
...
...
@@ -76,6 +77,8 @@ public class PayNotifyController {
public
Object
mepayCallback
(
@RequestBody
String
req
,
HttpServletResponse
resp
)
{
logger
.
info
(
"接收到微企付回调通知接口: "
+
req
);
List
<
Map
<
String
,
Object
>>
returnMap
=
orderService
.
mePayCallback
(
req
);
logger
.
info
(
"处理微企付回调信息结果 {}"
,
GsonUtil
.
toJson
(
returnMap
));
return
"success"
;
}
...
...
src/main/java/com/egolm/shop/api/service/OrderService.java
View file @
54ad0368
...
...
@@ -47,4 +47,6 @@ public interface OrderService {
public
List
<
Map
<
String
,
Object
>>
createSettlePay
(
String
settleNO
,
String
payTypeID
,
String
payType
,
String
payAmount
,
String
payCardNO
)
;
public
List
<
Map
<
String
,
Object
>>
payCallback
(
WxPayResponse
postData
);
public
List
<
Map
<
String
,
Object
>>
mePayCallback
(
String
req
);
}
src/main/java/com/egolm/shop/api/service/impl/OrderServiceImpl.java
View file @
54ad0368
...
...
@@ -1163,7 +1163,7 @@ public class OrderServiceImpl implements OrderService {
String
OpenID
=
postData
.
getOpenid
();
String
paydate
=
DateUtil
.
format
(
DateUtil
.
parse
(
PayDate
,
DateUtil
.
FMT_YYYYMMddHHMMSS
),
DateUtil
.
FMT_DATE_SECOND
);
logger
.
info
(
"支付回调单号: {}"
,
OutTradeNO
);
//补款后缀是_D,结算单后缀是_S
/
*/
/补款后缀是_D,结算单后缀是_S
if(OutTradeNO.contains("_D")) {
String sql = "exec up_B2BSalesOrderDebtPayCallBack '"+OutTradeNO+"' ,'"+TransactionID+"' , '"+PayCardNO+"' , '"+PayAmount+"' , '"+paydate+"' , '"+PayChannel+"' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
...
...
@@ -1173,13 +1173,103 @@ public class OrderServiceImpl implements OrderService {
}else {//普通订单
String[] ary = OutTradeNO.split("_", 2);
returnMap = this.paySuccess(ary[0], new BigDecimal(PayAmount), OpenID, TransactionID, OutTradeNO, DateUtil.parse(paydate, DateUtil.FMT_DATE_SECOND));
}
}*/
this
.
doCallBack
(
OutTradeNO
,
TransactionID
,
PayCardNO
,
PayAmount
,
paydate
,
PayChannel
,
OpenID
);
}
catch
(
Exception
e
)
{
logger
.
info
(
"支付回调异常 ,{} "
,
e
.
getMessage
());
}
return
returnMap
;
}
/**
* 微企付的回调 PayTypeID=140
* <p>Title: </p>
* <p>Description: </p>
* @param req
* @return
*/
public
List
<
Map
<
String
,
Object
>>
mePayCallback
(
String
req
){
String
PayTypeID
=
"140"
;
//微企付
List
<
Map
<
String
,
Object
>>
returnMap
=
new
ArrayList
<
Map
<
String
,
Object
>>();
JSONObject
reqObj
=
JSONObject
.
parseObject
(
req
);
if
(
reqObj
.
containsKey
(
"callback_from"
))
{
//mp支付预下单 自已定的回调,非微企付官方回调
String
paymentId
=
reqObj
.
getString
(
"paymentId"
);
String
outPaymentId
=
reqObj
.
getString
(
"outPaymentId"
);
//String payStatus = reqObj.getString("payStatus");
String
PayCardNO
=
reqObj
.
getString
(
"PayCardNO"
);
String
PayAmount
=
reqObj
.
getString
(
"PayAmount"
);
String
sql
=
"exec up_B2BSalesOrderPayUpdate '"
+
outPaymentId
+
"' ,'"
+
paymentId
+
"' , '"
+
PayCardNO
+
"' , '"
+
PayAmount
+
"' , '"
+
PayTypeID
+
"' "
;
returnMap
=
jdbcTemplate
.
executeMutil
(
sql
).
getDatas
().
get
(
0
);
}
else
{
//https://businesspay.qq.com/p/doc/mse/api/server.html#%E6%94%AF%E4%BB%98%E7%BB%93%E6%9E%9C%E9%80%9A%E7%9F%A5-2
//https://businesspay.qq.com/p/doc/mse/api/server.html#%E9%80%80%E6%AC%BE%E7%BB%93%E6%9E%9C%E9%80%9A%E7%9F%A5
//mse_payment.succeeded 支付成功
//mse_payment.close 支付关单
// mse_payment.revoke 支付退票
String
event_type
=
reqObj
.
getString
(
"event_type"
);
//
JSONObject
event_content
=
reqObj
.
getJSONObject
(
"event_content"
);
String
payment_id
=
event_content
.
getString
(
"payment_id"
);
//微企付支付单号
String
out_payment_id
=
event_content
.
getString
(
"out_payment_id"
);
//付款方 ID
if
(
event_type
.
equals
(
"mse_payment.succeeded"
)
||
event_type
.
equals
(
"mse_payment.close"
)
||
event_type
.
equals
(
"mse_payment.revoke"
))
{
//String openid = event_content.getString("purchaser_id");//个人付款时对应微企付用户openid
String
status
=
event_content
.
getString
(
"status"
);
String
PayAmount
=
event_content
.
getString
(
"amount"
);
String
pay_succ_time
=
status
.
equals
(
"SUCCEEDED"
)?
event_content
.
getString
(
"pay_succ_time"
):
""
;
String
StatusID
=
""
;
String
StatusName
=
""
;
switch
(
status
)
{
case
"SUCCEEDED"
:
StatusID
=
"1"
;
StatusName
=
"支付成功"
;
break
;
case
"CLOSED"
:
StatusID
=
"2"
;
StatusName
=
"支付关单"
;
break
;
case
"REVOKED"
:
StatusID
=
"3"
;
StatusName
=
"支付退票"
;
break
;
default
:
break
;
}
String
sql
=
"exec up_B2BSalesOrderPayCallBack '"
+
out_payment_id
+
"' ,'"
+
payment_id
+
"' , '"
+
PayAmount
+
"' , '"
+
pay_succ_time
+
"' , '"
+
PayTypeID
+
"' , '"
+
StatusID
+
"' , '"
+
StatusName
+
"' "
;
returnMap
=
jdbcTemplate
.
executeMutil
(
sql
).
getDatas
().
get
(
0
);
}
else
if
(
event_type
.
equals
(
"mse_refund.succeeded"
))
{
//退款成功
}
}
return
returnMap
;
}
public
List
<
Map
<
String
,
Object
>>
doCallBack
(
String
OutTradeNO
,
String
TransactionID
,
String
PayCardNO
,
String
PayAmount
,
String
paydate
,
String
PayChannel
,
String
OpenID
){
List
<
Map
<
String
,
Object
>>
returnMap
=
new
ArrayList
<
Map
<
String
,
Object
>>();
//补款后缀是_D,结算单后缀是_S
if
(
OutTradeNO
.
contains
(
"_D"
))
{
String
sql
=
"exec up_B2BSalesOrderDebtPayCallBack '"
+
OutTradeNO
+
"' ,'"
+
TransactionID
+
"' , '"
+
PayCardNO
+
"' , '"
+
PayAmount
+
"' , '"
+
paydate
+
"' , '"
+
PayChannel
+
"' "
;
returnMap
=
jdbcTemplate
.
executeMutil
(
sql
).
getDatas
().
get
(
0
);
}
else
if
(
OutTradeNO
.
contains
(
"_S"
))
{
String
sql
=
"exec up_CreateSettlePayCallBack '"
+
OutTradeNO
+
"' ,'"
+
TransactionID
+
"' , '"
+
PayCardNO
+
"' , '"
+
PayAmount
+
"' , '"
+
paydate
+
"' , '"
+
PayChannel
+
"' "
;
returnMap
=
jdbcTemplate
.
executeMutil
(
sql
).
getDatas
().
get
(
0
);
}
else
{
//普通订单
String
[]
ary
=
OutTradeNO
.
split
(
"_"
,
2
);
returnMap
=
this
.
paySuccess
(
ary
[
0
],
new
BigDecimal
(
PayAmount
),
OpenID
,
TransactionID
,
OutTradeNO
,
DateUtil
.
parse
(
paydate
,
DateUtil
.
FMT_DATE_SECOND
));
}
return
returnMap
;
}
//提交结算付款记录
@Override
public
List
<
Map
<
String
,
Object
>>
createSettlePay
(
String
settleNO
,
String
payTypeID
,
String
payType
,
...
...
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