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
f4c6b999
Commit
f4c6b999
authored
Nov 10, 2018
by
liuyuzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
小程序服务商模式付款
parent
e10ff338
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
92 additions
and
88 deletions
+92
-88
PayConst.php
application/library/Our/PayConst.php
+1
-1
TencentPay.php
application/library/Payment/TencentPay.php
+2
-3
WxLitePay.php
application/library/Payment/WxLitePay.php
+71
-0
WxPay.php
application/library/Payment/WxPay.php
+1
-79
1517411161_20181102_cert.p12
...brary/Payment/cert/wxservice/1517411161_20181102_cert.p12
+0
-0
1517411161_20181102_cert.pem
...brary/Payment/cert/wxservice/1517411161_20181102_cert.pem
+0
-0
1517411161_20181102_key.pem
...ibrary/Payment/cert/wxservice/1517411161_20181102_key.pem
+0
-0
OrderService.php
application/models/Business/Order/OrderService.php
+11
-0
RefundReturn.php
application/models/DAO/Order/RefundReturn.php
+5
-4
cancelOne.php
scripts/crontab/order/cancelOne.php
+1
-1
No files found.
application/library/Our/PayConst.php
View file @
f4c6b999
...
@@ -21,7 +21,7 @@ class PayConst {
...
@@ -21,7 +21,7 @@ class PayConst {
const
wxSPayMchId
=
'1517411161'
;
const
wxSPayMchId
=
'1517411161'
;
const
wxSPayKey
=
'z6o0aQ4Gbceaymj6BKm9PYPjHaUJGokJ'
;
const
wxSPayKey
=
'z6o0aQ4Gbceaymj6BKm9PYPjHaUJGokJ'
;
const
wxServiceSslcertPath
=
'/application/library/Payment/cert/wxservice/1517411161_20181102_cert.pem'
;
const
wxServiceSslcertPath
=
'/application/library/Payment/cert/wxservice/1517411161_20181102_cert.pem'
;
const
wxServiceSslkeyPath
=
'/application/library/Payment/cert/wxservice/1517411161_20181102.pem'
;
const
wxServiceSslkeyPath
=
'/application/library/Payment/cert/wxservice/1517411161_20181102
_key
.pem'
;
const
wxPayUrl
=
'https://api.mch.weixin.qq.com/pay/unifiedorder'
;
const
wxPayUrl
=
'https://api.mch.weixin.qq.com/pay/unifiedorder'
;
...
...
application/library/Payment/TencentPay.php
View file @
f4c6b999
...
@@ -131,6 +131,7 @@ class TencentPay {
...
@@ -131,6 +131,7 @@ class TencentPay {
function
createXml
(
$signType
=
'MD5'
)
function
createXml
(
$signType
=
'MD5'
)
{
{
if
(
$signType
==
'MD5'
){
if
(
$signType
==
'MD5'
){
//echo '加签参数:'.json_encode($this->parameters)."\n";
$this
->
parameters
[
"sign"
]
=
$this
->
getSign
(
$this
->
parameters
);
//签名
$this
->
parameters
[
"sign"
]
=
$this
->
getSign
(
$this
->
parameters
);
//签名
}
else
{
}
else
{
$this
->
parameters
[
"sign"
]
=
$this
->
getHMACSHA1Sign
(
$this
->
parameters
,
'sha256'
);
$this
->
parameters
[
"sign"
]
=
$this
->
getHMACSHA1Sign
(
$this
->
parameters
,
'sha256'
);
...
@@ -262,8 +263,7 @@ class TencentPay {
...
@@ -262,8 +263,7 @@ class TencentPay {
$String
=
$this
->
formatBizQueryParaMap
(
$Parameters
,
false
);
$String
=
$this
->
formatBizQueryParaMap
(
$Parameters
,
false
);
$String
=
$String
.
"&key="
.
$this
->
key
;
$String
=
$String
.
"&key="
.
$this
->
key
;
\Our\Log
::
getInstance
()
->
write
(
$this
->
key
,
'/data/log/applognew'
);
$String
=
str_replace
(
array
(
"
\r\n
"
,
"
\r
"
,
"
\n
"
,
" "
),
""
,
$String
);
//签名步骤三:MD5加密
$String
=
md5
(
$String
);
$String
=
md5
(
$String
);
$result_
=
strtoupper
(
$String
);
$result_
=
strtoupper
(
$String
);
return
$result_
;
return
$result_
;
...
@@ -342,7 +342,6 @@ class TencentPay {
...
@@ -342,7 +342,6 @@ class TencentPay {
$this
->
setReturnParameter
(
"return_code"
,
"SUCCESS"
);
//设置返回码
$this
->
setReturnParameter
(
"return_code"
,
"SUCCESS"
);
//设置返回码
}
}
$returnXml
=
$this
->
returnXml
();
$returnXml
=
$this
->
returnXml
();
\Our\Log
::
getInstance
()
->
write
(
json_encode
(
$this
->
data
,
true
),
'/data/log/applog'
);
if
(
$verify
)
{
if
(
$verify
)
{
return
array
(
return
array
(
'out_trade_no'
=>
$this
->
data
[
'out_trade_no'
],
'out_trade_no'
=>
$this
->
data
[
'out_trade_no'
],
...
...
application/library/Payment/WxLitePay.php
View file @
f4c6b999
...
@@ -8,6 +8,7 @@ namespace Payment;
...
@@ -8,6 +8,7 @@ namespace Payment;
*/
*/
class
WxLitePay
extends
\Payment\TencentPay
{
class
WxLitePay
extends
\Payment\TencentPay
{
private
$refundUrl
=
"https://api.mch.weixin.qq.com/secapi/pay/refund"
;
public
function
__construct
()
public
function
__construct
()
{
{
$this
->
appid
=
\Our\PayConst
::
wxLiteAppId
;
$this
->
appid
=
\Our\PayConst
::
wxLiteAppId
;
...
@@ -51,6 +52,76 @@ class WxLitePay extends \Payment\TencentPay{
...
@@ -51,6 +52,76 @@ class WxLitePay extends \Payment\TencentPay{
}
}
public
function
refund
(
$param
){
if
(
$param
[
'subMchId'
]){
$this
->
refundService
(
$param
);
}
else
{
$this
->
refundCommon
(
$param
);
}
}
public
function
refundService
(
$param
){
$this
->
key
=
$this
->
s_key
;
$this
->
sslcert_path
=
\Our\PayConst
::
wxServiceSslcertPath
;
$this
->
sslkey_path
=
\Our\PayConst
::
wxServiceSslkeyPath
;
$total_fee
=
intval
(
$param
[
'totalFee'
]);
$refund_fee
=
intval
(
$param
[
'refundFee'
]);
if
(
APP_ENV
==
'develop'
||
APP_ENV
==
'test'
||
APP_ENV
==
'pre'
||
APP_ENV
==
'ccwdevelop'
||
APP_ENV
==
'lyztest'
){
$this
->
parameters
[
'total_fee'
]
=
1
;
$this
->
parameters
[
'refund_fee'
]
=
1
;
}
else
{
$this
->
parameters
[
'total_fee'
]
=
$total_fee
;
$this
->
parameters
[
'refund_fee'
]
=
$refund_fee
;
}
$this
->
parameters
[
'appid'
]
=
$this
->
s_appid
;
$this
->
parameters
[
'mch_id'
]
=
$this
->
s_mch_id
;
$this
->
parameters
[
'sub_appid'
]
=
$this
->
appid
;
$this
->
parameters
[
'sub_mch_id'
]
=
$param
[
'subMchId'
];
$this
->
parameters
[
'nonce_str'
]
=
$this
->
createNoncestr
(
32
);
//$this->parameters['transaction_id'] = $param['transactionId'];
$this
->
parameters
[
'out_trade_no'
]
=
$param
[
'outTradeNo'
];
$this
->
parameters
[
'out_refund_no'
]
=
$param
[
'refundOrderNo'
];
$xml
=
$this
->
createXml
();
$response
=
$this
->
postXmlSSLCurl
(
$xml
,
$this
->
refundUrl
,
6
);
$values
=
$this
->
xmlToArray
(
$response
);
if
(
$values
[
'return_code'
]
!=
'SUCCESS'
)
{
return
$values
;
}
$this
->
checkSign
(
$values
);
return
$values
;
}
public
function
refundCommon
(
$param
){
$total_fee
=
intval
(
$param
[
'totalFee'
]);
$refund_fee
=
intval
(
$param
[
'refundFee'
]);
if
(
APP_ENV
==
'develop'
||
APP_ENV
==
'test'
||
APP_ENV
==
'pre'
||
APP_ENV
==
'ccwdevelop'
){
$this
->
parameters
[
'total_fee'
]
=
1
;
$this
->
parameters
[
'refund_fee'
]
=
1
;
}
else
{
$this
->
parameters
[
'total_fee'
]
=
$total_fee
;
$this
->
parameters
[
'refund_fee'
]
=
$refund_fee
;
}
$this
->
parameters
[
'out_refund_no'
]
=
$param
[
'refundOrderNo'
];
$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
::
wxLiteAppId
;
$this
->
parameters
[
'mch_id'
]
=
\Our\PayConst
::
wxPayMchId
;
$xml
=
$this
->
createXml
();
$response
=
$this
->
postXmlSSLCurl
(
$xml
,
$this
->
refundUrl
,
6
);
$values
=
$this
->
xmlToArray
(
$response
);
if
(
$values
[
'return_code'
]
!=
'SUCCESS'
)
{
return
$values
;
}
$this
->
checkSign
(
$values
);
return
$values
;
}
/**
/**
* 类实例
* 类实例
*
*
...
...
application/library/Payment/WxPay.php
View file @
f4c6b999
...
@@ -58,18 +58,6 @@ class WxPay extends \Payment\TencentPay
...
@@ -58,18 +58,6 @@ class WxPay extends \Payment\TencentPay
return
$wxApiObj
;
return
$wxApiObj
;
}
}
/**
* 作用:产生随机字符串,不长于32位
*/
private
function
createNoncestr
(
$length
=
32
)
{
$chars
=
"abcdefghijklmnopqrstuvwxyz0123456789"
;
$str
=
""
;
for
(
$i
=
0
;
$i
<
$length
;
$i
++
)
{
$str
.=
substr
(
$chars
,
mt_rand
(
0
,
strlen
(
$chars
)
-
1
),
1
);
}
return
$str
;
}
public
function
refund
(
$param
){
public
function
refund
(
$param
){
if
(
$param
[
'subMchId'
]){
if
(
$param
[
'subMchId'
]){
...
@@ -80,6 +68,7 @@ class WxPay extends \Payment\TencentPay
...
@@ -80,6 +68,7 @@ class WxPay extends \Payment\TencentPay
}
}
public
function
serviceRefund
(
$param
){
public
function
serviceRefund
(
$param
){
$this
->
key
=
$this
->
s_key
;
$this
->
sslcert_path
=
\Our\PayConst
::
wxServiceSslcertPath
;
$this
->
sslcert_path
=
\Our\PayConst
::
wxServiceSslcertPath
;
$this
->
sslkey_path
=
\Our\PayConst
::
wxServiceSslkeyPath
;
$this
->
sslkey_path
=
\Our\PayConst
::
wxServiceSslkeyPath
;
$total_fee
=
intval
(
$param
[
'totalFee'
]);
$total_fee
=
intval
(
$param
[
'totalFee'
]);
...
@@ -140,73 +129,6 @@ class WxPay extends \Payment\TencentPay
...
@@ -140,73 +129,6 @@ class WxPay extends \Payment\TencentPay
return
$values
;
return
$values
;
}
}
public
function
refundWxProgram
(
$param
){
if
(
$param
[
'subMchId'
]){
$this
->
refundServiceWxProgram
(
$param
);
}
else
{
$this
->
refundCommonWxProgram
(
$param
);
}
}
public
function
refundServiceWxProgram
(
$param
){
$this
->
sslcert_path
=
\Our\PayConst
::
wxServiceSslcertPath
;
$this
->
sslkey_path
=
\Our\PayConst
::
wxServiceSslkeyPath
;
$total_fee
=
intval
(
$param
[
'totalFee'
]);
$refund_fee
=
intval
(
$param
[
'refundFee'
]);
if
(
APP_ENV
==
'develop'
||
APP_ENV
==
'test'
||
APP_ENV
==
'pre'
||
APP_ENV
==
'ccwdevelop'
){
$this
->
parameters
[
'total_fee'
]
=
1
;
$this
->
parameters
[
'refund_fee'
]
=
1
;
}
else
{
$this
->
parameters
[
'total_fee'
]
=
$total_fee
;
$this
->
parameters
[
'refund_fee'
]
=
$refund_fee
;
}
$this
->
parameters
[
'total_fee'
]
=
$total_fee
;
$this
->
parameters
[
'refund_fee'
]
=
$refund_fee
;
$this
->
parameters
[
'out_refund_no'
]
=
$param
[
'refundOrderNo'
];
$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
::
wxSPayAppId
;
$this
->
parameters
[
'mch_id'
]
=
\Our\PayConst
::
wxSPayMchId
;
$this
->
parameters
[
'sub_appid'
]
=
\Our\PayConst
::
wxLiteAppId
;
$this
->
parameters
[
'sub_mch_id '
]
=
$param
[
'subMchId'
];
$xml
=
$this
->
createXml
();
$response
=
$this
->
postXmlSSLCurl
(
$xml
,
$this
->
refundUrl
,
6
,
true
);
$values
=
$this
->
xmlToArray
(
$response
);
if
(
$values
[
'return_code'
]
!=
'SUCCESS'
)
{
return
$values
;
}
$this
->
checkSign
(
$values
);
return
$values
;
}
public
function
refundCommonWxProgram
(
$param
){
$total_fee
=
intval
(
$param
[
'totalFee'
]);
$refund_fee
=
intval
(
$param
[
'refundFee'
]);
if
(
APP_ENV
==
'develop'
||
APP_ENV
==
'test'
||
APP_ENV
==
'pre'
||
APP_ENV
==
'ccwdevelop'
){
$this
->
parameters
[
'total_fee'
]
=
1
;
$this
->
parameters
[
'refund_fee'
]
=
1
;
}
else
{
$this
->
parameters
[
'total_fee'
]
=
$total_fee
;
$this
->
parameters
[
'refund_fee'
]
=
$refund_fee
;
}
$this
->
parameters
[
'out_refund_no'
]
=
$param
[
'refundOrderNo'
];
$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
::
wxLiteAppId
;
$this
->
parameters
[
'mch_id'
]
=
\Our\PayConst
::
wxPayMchId
;
$xml
=
$this
->
createXml
();
$response
=
$this
->
postXmlSSLCurl
(
$xml
,
$this
->
refundUrl
,
6
);
$values
=
$this
->
xmlToArray
(
$response
);
if
(
$values
[
'return_code'
]
!=
'SUCCESS'
)
{
return
$values
;
}
$this
->
checkSign
(
$values
);
return
$values
;
}
/**
/**
* 类实例
* 类实例
*
*
...
...
application/library/Payment/cert/wxservice/1517411161_20181102_cert.p12
100644 → 100755
View file @
f4c6b999
File mode changed from 100644 to 100755
application/library/Payment/cert/wxservice/1517411161_20181102_cert.pem
100644 → 100755
View file @
f4c6b999
File mode changed from 100644 to 100755
application/library/Payment/cert/wxservice/1517411161_20181102_key.pem
100644 → 100755
View file @
f4c6b999
File mode changed from 100644 to 100755
application/models/Business/Order/OrderService.php
View file @
f4c6b999
...
@@ -306,6 +306,7 @@ class OrderServiceModel extends \Business\AbstractModel
...
@@ -306,6 +306,7 @@ class OrderServiceModel extends \Business\AbstractModel
$order
=
$orderDao
->
findByOrderId
(
$orderId
,
$orderDao
->
getOrderDetailField
());
$order
=
$orderDao
->
findByOrderId
(
$orderId
,
$orderDao
->
getOrderDetailField
());
//判断订单目前状态是否允许取消
//判断订单目前状态是否允许取消
$isAllowCancel
=
$orderDao
->
isAllowCancel
(
$order
);
$isAllowCancel
=
$orderDao
->
isAllowCancel
(
$order
);
$isAllowCance
=
true
;
if
(
$isAllowCancel
)
{
if
(
$isAllowCancel
)
{
$res
=
$orderDao
->
updateStatusByOrderId
(
$orderId
,
ApiConst
::
orderStateCancel
);
$res
=
$orderDao
->
updateStatusByOrderId
(
$orderId
,
ApiConst
::
orderStateCancel
);
if
(
$res
)
{
if
(
$res
)
{
...
@@ -331,6 +332,16 @@ class OrderServiceModel extends \Business\AbstractModel
...
@@ -331,6 +332,16 @@ class OrderServiceModel extends \Business\AbstractModel
}
}
public
function
cancelOne
(){
$refundReturnDao
=
\DAO\Order\RefundReturnModel
::
getInstance
(
DbNameConst
::
masterDBConnectName
);
$orderData
[
'storeId'
]
=
11
;
$orderData
[
'subMchId'
]
=
'1517943841'
;
$orderData
[
'paySn'
]
=
'280595075137008428'
;
$orderData
[
'transactionId'
]
=
'4200000191201811099414332980'
;
$orderData
[
'buyerId'
]
=
428
;
$resultRefund
=
$refundReturnDao
->
refundMoney
(
$orderData
);
}
//确认收货
//确认收货
public
function
confirmRecieve
(
$orderId
,
$memberId
)
public
function
confirmRecieve
(
$orderId
,
$memberId
)
{
{
...
...
application/models/DAO/Order/RefundReturn.php
View file @
f4c6b999
...
@@ -340,10 +340,11 @@ class RefundReturnModel extends \DAO\AbstractModel {
...
@@ -340,10 +340,11 @@ class RefundReturnModel extends \DAO\AbstractModel {
return
false
;
return
false
;
}
}
}
else
if
(
intval
(
$orderInfo
[
'paymentType'
])
==
ApiConst
::
wxProgram
){
}
else
if
(
intval
(
$orderInfo
[
'paymentType'
])
==
ApiConst
::
wxProgram
){
$wxpay
=
\Payment\WxPay
::
getInstance
();
$wxpay
=
\Payment\WxLitePay
::
getInstance
();
$param
[
'subMchId'
]
=
'1517943841'
;
if
(
$orderInfo
[
'subMchId'
]){
$refund_return
=
$wxpay
->
refundWxProgram
(
$param
);
$param
[
'subMchId'
]
=
$orderInfo
[
'subMchId'
];
$this
->
errorMessage
=
"微信小程序返回:"
.
json_encode
(
$refund_return
);
}
$refund_return
=
$wxpay
->
refund
(
$param
);
if
(
!
(
$refund_return
[
'return_code'
]
==
'SUCCESS'
&&
$refund_return
[
'result_code'
]
==
'SUCCESS'
))
{
if
(
!
(
$refund_return
[
'return_code'
]
==
'SUCCESS'
&&
$refund_return
[
'result_code'
]
==
'SUCCESS'
))
{
$this
->
errorMessage
=
date
(
'Y-m-d'
)
.
'微信退款操作执行失败!'
.
$orderInfo
[
'orderId'
]
.
"
\r\n
"
;
$this
->
errorMessage
=
date
(
'Y-m-d'
)
.
'微信退款操作执行失败!'
.
$orderInfo
[
'orderId'
]
.
"
\r\n
"
;
return
false
;
return
false
;
...
...
scripts/crontab/order/cancelOne.php
View file @
f4c6b999
...
@@ -41,7 +41,7 @@ class cliOrderCancel extends basecli
...
@@ -41,7 +41,7 @@ class cliOrderCancel extends basecli
protected
function
autoCancelOrder
(){
protected
function
autoCancelOrder
(){
$orderService
=
\Business\Order\OrderServiceModel
::
getInstance
(
\Our\DbNameConst
::
masterDBConnectName
);
$orderService
=
\Business\Order\OrderServiceModel
::
getInstance
(
\Our\DbNameConst
::
masterDBConnectName
);
$orderService
->
cancel
(
2031
);
$orderService
->
cancel
One
(
);
}
}
protected
function
_runCli
()
protected
function
_runCli
()
{
{
...
...
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