Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
my-yaf-project
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
chenchuanwen
my-yaf-project
Commits
382c6bbb
Commit
382c6bbb
authored
Nov 09, 2018
by
liuyuzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
小程序支付
parent
ba7a12e4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
6 deletions
+102
-6
TencentPay.php
application/library/Payment/TencentPay.php
+11
-3
WxPay.php
application/library/Payment/WxPay.php
+3
-3
RefundReturn.php
application/models/DAO/Order/RefundReturn.php
+1
-0
cancelOne.php
scripts/crontab/order/cancelOne.php
+87
-0
No files found.
application/library/Payment/TencentPay.php
View file @
382c6bbb
...
...
@@ -21,6 +21,8 @@ class TencentPay {
protected
$s_appid
=
''
;
protected
$s_key
=
''
;
protected
$s_mch_id
=
''
;
protected
$s_sslcert_path
=
'application/library/Payment/cert/wxservice/1517411161_20181102_cert.pem'
;
protected
$s_sslkey_path
=
'application/library/Payment/cert/wxservice/1517411161_20181102_key.pem'
;
protected
$prepay_id
=
''
;
protected
$tradeType
=
''
;
public
$data
;
//接收到的数据,类型为关联数组
...
...
@@ -203,8 +205,14 @@ class TencentPay {
/**
* 作用:使用证书,以post方式提交xml到对应的接口url
*/
function
postXmlSSLCurl
(
$xml
,
$url
,
$second
=
30
)
function
postXmlSSLCurl
(
$xml
,
$url
,
$second
=
30
,
$serviceFlag
=
false
)
{
$certPath
=
APPLICATION_PATH
.
$this
->
sslcert_path
;
$keyPath
=
APPLICATION_PATH
.
$this
->
sslkey_path
;
if
(
$serviceFlag
){
$certPath
=
APPLICATION_PATH
.
$this
->
s_sslcert_path
;
$keyPath
=
APPLICATION_PATH
.
$this
->
s_sslkey_path
;
}
$ch
=
curl_init
();
//超时时间
curl_setopt
(
$ch
,
CURLOPT_TIMEOUT
,
$second
);
...
...
@@ -222,10 +230,10 @@ class TencentPay {
//使用证书:cert 与 key 分别属于两个.pem文件
//默认格式为PEM,可以注释
curl_setopt
(
$ch
,
CURLOPT_SSLCERTTYPE
,
'PEM'
);
curl_setopt
(
$ch
,
CURLOPT_SSLCERT
,
APPLICATION_PATH
.
$this
->
sslcert_p
ath
);
curl_setopt
(
$ch
,
CURLOPT_SSLCERT
,
$certP
ath
);
//默认格式为PEM,可以注释
curl_setopt
(
$ch
,
CURLOPT_SSLKEYTYPE
,
'PEM'
);
curl_setopt
(
$ch
,
CURLOPT_SSLKEY
,
APPLICATION_PATH
.
$this
->
sslkey_p
ath
);
curl_setopt
(
$ch
,
CURLOPT_SSLKEY
,
$keyP
ath
);
//post提交方式
curl_setopt
(
$ch
,
CURLOPT_POST
,
true
);
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$xml
);
...
...
application/library/Payment/WxPay.php
View file @
382c6bbb
...
...
@@ -168,12 +168,12 @@ class WxPay extends \Payment\TencentPay
$this
->
parameters
[
'out_trade_no'
]
=
$param
[
'outTradeNo'
];
$this
->
parameters
[
'op_user_id'
]
=
$this
->
mch_id
;
$this
->
parameters
[
'nonce_str'
]
=
$this
->
createNoncestr
(
32
);
$this
->
parameters
[
'appid'
]
=
\Our\PayConst
::
wx
Lite
AppId
;
$this
->
parameters
[
'appid'
]
=
\Our\PayConst
::
wx
SPay
AppId
;
$this
->
parameters
[
'mch_id'
]
=
\Our\PayConst
::
wxSPayMchId
;
$this
->
parameters
[
'sub_appid'
]
=
\Our\PayConst
::
wx
SPay
AppId
;
$this
->
parameters
[
'sub_appid'
]
=
\Our\PayConst
::
wx
Lite
AppId
;
$this
->
parameters
[
'sub_mch_id '
]
=
$param
[
'subMchId'
];
$xml
=
$this
->
createXml
();
$response
=
$this
->
postXmlSSLCurl
(
$xml
,
$this
->
refundUrl
,
6
);
$response
=
$this
->
postXmlSSLCurl
(
$xml
,
$this
->
refundUrl
,
6
,
true
);
$values
=
$this
->
xmlToArray
(
$response
);
if
(
$values
[
'return_code'
]
!=
'SUCCESS'
)
{
return
$values
;
...
...
application/models/DAO/Order/RefundReturn.php
View file @
382c6bbb
...
...
@@ -341,6 +341,7 @@ class RefundReturnModel extends \DAO\AbstractModel {
}
}
else
if
(
intval
(
$orderInfo
[
'paymentType'
])
==
ApiConst
::
wxProgram
){
$wxpay
=
\Payment\WxPay
::
getInstance
();
$param
[
'subMchId'
]
=
'1517943841'
;
$refund_return
=
$wxpay
->
refundWxProgram
(
$param
);
$this
->
errorMessage
=
"微信小程序返回:"
.
json_encode
(
$refund_return
);
if
(
!
(
$refund_return
[
'return_code'
]
==
'SUCCESS'
&&
$refund_return
[
'result_code'
]
==
'SUCCESS'
))
{
...
...
scripts/crontab/order/cancelOne.php
0 → 100644
View file @
382c6bbb
<?php
/**
* User: liuyuzhen
* Date: 2018/11/9
* Time: 11:04
* Description:
*/
define
(
"APPLICATION_PATH"
,
realpath
(
dirname
(
__FILE__
)
.
'/../../../'
));
//指向public的上一级
require
APPLICATION_PATH
.
'/scripts/crontab/baseCli.php'
;
require
APPLICATION_PATH
.
'/scripts/crontab/common.php'
;
error_reporting
(
E_ALL
^
E_NOTICE
);
class
cliOrderCancel
extends
basecli
{
const
CLI_ADMIN_ID
=
255
;
private
$bDoUnLock
=
FALSE
;
// 是否允许释放 LOCK 文件
private
$_debug
=
0
;
private
$lockFileName
;
private
$fromState
;
private
function
mkdirs
(
$dir
,
$mode
=
0777
)
{
if
(
is_dir
(
$dir
)
||
@
mkdir
(
$dir
,
$mode
)){
return
TRUE
;
}
if
(
!
$this
->
mkdirs
(
dirname
(
$dir
),
$mode
)){
return
FALSE
;
}
return
@
mkdir
(
$dir
,
$mode
);
}
/**
* 析构
*/
public
function
__destruct
()
{
parent
::
__destruct
();
if
(
$this
->
bDoUnLock
)
{
@
unlink
(
$this
->
lockFileName
);
}
}
protected
function
autoCancelOrder
(){
$orderService
=
\Business\Order\OrderServiceModel
::
getInstance
(
\Our\DbNameConst
::
masterDBConnectName
);
$orderService
->
cancel
(
2031
);
}
protected
function
_runCli
()
{
$this
->
_debug
=
isset
(
$this
->
aArgv
[
1
])
?
intval
(
$this
->
aArgv
[
1
])
:
0
;
if
(
$this
->
_debug
)
{
echo
"*** Debug mode ***
\n
"
;
}
// Step: 02 检查是否已有相同CLI在运行中
$lockDir
=
$this
->
_getBaseFileName
(
'order'
);
if
(
!
$this
->
mkdirs
(
$lockDir
)){
echo
'****create dir fail ****'
;
exit
;
}
$this
->
lockFileName
=
$lockDir
.
DS
.
'cancel.locks'
;
if
(
file_exists
(
$this
->
lockFileName
)
)
{
$stat
=
stat
(
$this
->
lockFileName
);
if
(
(
TIMESTAMP
-
$stat
[
'mtime'
])
>
1800
)
{
echo
"文件被锁超过1800秒,被强制删除"
;
@
unlink
(
$this
->
lockFileName
);
}
else
{
$this
->
halt
(
'['
.
date
(
'Y-m-d H:i:s'
)
.
'] The CLI is running'
.
"
\n
"
);
}
}
$this
->
bDoUnLock
=
true
;
if
(
APP_ENV
==
'pre'
||
APP_ENV
==
'product'
){
file_put_contents
(
$this
->
lockFileName
,
"running"
);
// CLI 独占锁
}
$this
->
autoCancelOrder
();
echo
'定单取消成功'
.
"
\r\n
"
;
}
}
$oCli
=
new
cliOrderCancel
(
TRUE
);
EXIT
;
?>
\ No newline at end of file
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