Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
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
方斌
51business
Commits
3e285ab1
Commit
3e285ab1
authored
Sep 09, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wexin pay
parent
90359d5a
Pipeline
#13535
passed with stage
in 9 minutes 41 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
4 deletions
+44
-4
common.js
app/service/credit/common.js
+44
-4
No files found.
app/service/credit/common.js
View file @
3e285ab1
...
@@ -102,7 +102,7 @@ class CommonService extends Service {
...
@@ -102,7 +102,7 @@ class CommonService extends Service {
};
};
await
this
.
addCreditPay
(
pay_data
);
await
this
.
addCreditPay
(
pay_data
);
return
{
url
:
ret
.
mweb_url
};
return
{
url
:
ret
.
mweb_url
,
order_id
:
order_id
,
trade_no
:
data
.
trade_no
};
}
else
if
(
type
===
'alipay'
)
{
}
else
if
(
type
===
'alipay'
)
{
//TODO
//TODO
...
@@ -185,9 +185,49 @@ class CommonService extends Service {
...
@@ -185,9 +185,49 @@ class CommonService extends Service {
async
WexinCheckPay
(
params
)
{
async
WexinCheckPay
(
params
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
{
transaction_id
,
out_trade_no
,
nonce_str
}
=
params
;
const
{
transaction_id
,
trade_no
}
=
params
;
const
pay_info
=
await
ctx
.
prometheusModel
.
CreditPay
.
one
({
where
:
{
trade_no
:
out_trade_no
}
});
if
(
!
pay_info
||
pay_info
.
order_id
)
{
ctx
.
failed
(
'pay info error'
);
}
const
order_info
=
await
ctx
.
service
.
credit
.
common
.
getOrderInfo
(
pay_info
.
order_id
);
const
nonce_str
=
ctx
.
helper
.
createNoncestr
();
const
url
=
'https://api.mch.weixin.qq.com/pay/orderquery'
;
let
data_obj
=
{
appid
:
this
.
config
.
MCH_APPID
,
mch_id
:
this
.
config
.
MCH_ID
,
transaction_id
,
out_trade_no
:
trade_no
,
nonce_str
,
}
const
sign
=
this
.
getWexinSign
(
data_obj
);
data_obj
.
sign
=
sign
;
const
xml_data
=
ctx
.
helper
.
jsonToxml
(
data_obj
);
const
result_wexin
=
await
ctx
.
curl
(
url
,
{
timeout
:
3000
,
method
:
'POST'
,
data
:
xml_data
,
headers
:
{
'content-type'
:
'text/html'
,
},
streaming
:
false
,
dataType
:
'text'
,
});
if
(
result_wexin
.
status
)
{
ctx
.
failed
(
'wexin orderquery error1'
);
}
const
ret
=
await
ctx
.
helper
.
xmlTojson
(
result_wexin
.
data
);
if
(
ret
.
return_code
!==
'SUCCESS'
&&
ret
.
result_code
!==
'SUCCESS'
)
{
ctx
.
failed
(
'wexin orderquery error2'
);
}
let
ret_data
=
{};
for
(
let
key
in
ret
)
{
ret_data
[
key
]
=
ret
[
key
][
0
];
}
if
(
ret_data
.
trade_state
===
'SUCCESS'
)
{
return
false
;
}
const
price
=
order_info
.
price
*
100
-
order_info
.
preferential_price
*
100
;
if
(
price
!=
ret_data
.
cash_fee
)
{
return
false
;
}
await
ctx
.
prometheusModel
.
CreditPay
.
edit
({
where
:
{
id
:
pay_info
.
id
},
params
:
{
pay_result
:
JSON
.
stringify
(
ret_data
),
status
:
1
}
});
return
true
;
}
}
/**
/**
...
...
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