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
43dac90f
Commit
43dac90f
authored
Dec 14, 2018
by
liuyuzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支付测试
parent
a947d714
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
4 deletions
+66
-4
TencentPay.php
application/library/Payment/TencentPay.php
+22
-2
WxLitePay.php
application/library/Payment/WxLitePay.php
+2
-2
OrderService.php
application/models/Business/Order/OrderService.php
+23
-0
PaymentService.php
application/models/Business/Order/PaymentService.php
+17
-0
CodeConfig.php
application/models/Error/CodeConfig.php
+2
-0
No files found.
application/library/Payment/TencentPay.php
View file @
43dac90f
...
...
@@ -12,6 +12,7 @@ class TencentPay {
protected
$sslkey_path
=
'/application/library/Payment/cert/qq/apiclient_key.pem'
;
protected
$appid
=
''
;
protected
$pay_url
=
"https://qpay.qq.com/cgi-bin/pay/qpay_unified_order.cgi"
;
protected
$orderquery_url
=
'https://api.mch.weixin.qq.com/pay/orderquery'
;
protected
$curl_timeout
=
30
;
protected
$notify_url
=
''
;
protected
$response
=
''
;
...
...
@@ -107,6 +108,25 @@ class TencentPay {
return
$prepay_id
;
}
function
getOrderPayResult
(
$pay_sn
,
$serviceFlag
=
false
){
if
(
$serviceFlag
){
$this
->
parameters
[
'appid'
]
=
$this
->
appid
;
$this
->
parameters
[
'mch_id'
]
=
$this
->
mch_id
;
}
else
{
$this
->
parameters
[
'appid'
]
=
$this
->
s_appid
;
$this
->
parameters
[
'mch_id'
]
=
$this
->
s_mch_id
;
$this
->
key
=
$this
->
s_key
;
}
$this
->
parameters
[
'out_trade_no'
]
=
$pay_sn
;
$this
->
parameters
[
'nonce_str'
]
=
\Our\CommonExtension
::
createNoncestr
(
32
);
$this
->
postXml
(
$this
->
orderquery_url
);
$this
->
result
=
$this
->
xmlToArray
(
$this
->
response
);
if
(
$this
->
result
[
'return_code'
]
==
"SUCCESS"
&&
$this
->
result
[
'result_code'
]
==
"SUCCESS"
&&
$this
->
result
[
'trade_state'
]
==
"SUCCESS"
){
return
true
;
}
return
false
;
}
/**
* 作用:将xml转为array
*/
...
...
@@ -121,11 +141,11 @@ class TencentPay {
/**
* 作用:post请求xml
*/
function
postXml
()
function
postXml
(
$url
=
false
)
{
$xml
=
$this
->
createXml
();
\Our\Log
::
getInstance
()
->
write
(
$xml
,
'/data/log/applog'
);
$this
->
response
=
$this
->
postXmlCurl
(
$xml
,
$this
->
pay_url
,
$this
->
curl_timeout
);
$this
->
response
=
$this
->
postXmlCurl
(
$xml
,
$
url
?
$url
:
$
this
->
pay_url
,
$this
->
curl_timeout
);
\Our\Log
::
getInstance
()
->
write
(
serialize
(
$this
->
response
),
'/data/log/applog'
);
return
$this
->
response
;
}
...
...
application/library/Payment/WxLitePay.php
View file @
43dac90f
...
...
@@ -12,8 +12,8 @@ class WxLitePay extends \Payment\TencentPay{
public
function
__construct
()
{
$this
->
appid
=
\Our\PayConst
::
wxLiteAppId
;
//
$this->notify_url = \Our\Common::getBaseUrl().\Our\PayConst::wxLiteNotifyUrl;
$this
->
notify_url
=
\Our\NameConst
::
httpPrefix
.
$_SERVER
[
'SERVER_NAME'
]
.
\Our\PayConst
::
wxLiteNotifyUrl
;
$this
->
notify_url
=
\Our\Common
::
getBaseUrl
()
.
\Our\PayConst
::
wxLiteNotifyUrl
;
//
$this->notify_url = \Our\NameConst::httpPrefix. $_SERVER['SERVER_NAME'] .\Our\PayConst::wxLiteNotifyUrl;
$this
->
mch_id
=
\Our\PayConst
::
wxPayMchId
;
$this
->
key
=
\Our\PayConst
::
wxSPayKey
;
$this
->
sslcert_path
=
\Our\PayConst
::
wxSslcertPath
;
...
...
application/models/Business/Order/OrderService.php
View file @
43dac90f
...
...
@@ -1161,6 +1161,29 @@ class OrderServiceModel extends \Business\AbstractModel
if
(
!
$orderList
)
{
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
noOrderListForPaySn
);
}
$orderPayModel
=
\DAO\Order\OrderPayModel
::
getInstance
();
$paySn
=
$data
[
'paySn'
];
$oldOrderPay
=
$orderPayModel
->
find
(
array
(
'pay_sn'
=>
$paySn
));
$orderStateArray
=
array_column
(
$orderList
,
'order_state'
);
if
(
in_array
(
\Our\ApiConst
::
orderStateWaitPay
,
$orderStateArray
)
&&
in_array
(
$oldOrderPay
[
'pay_type'
],
array
(
\Our\ApiConst
::
wxAppPayType
,
\Our\ApiConst
::
wxLitePayType
))){
if
(
$oldOrderPay
[
'pay_type'
]
==
\Our\ApiConst
::
wxLitePayType
){
$wxLitePay
=
\Payment\WxLitePay
::
getInstance
();
$payResult
=
$wxLitePay
->
getOrderPayResult
(
$paySn
,
true
);
}
else
{
$wxPay
=
\Payment\WxPay
::
getInstance
();
$payResult
=
$wxPay
->
getOrderPayResult
(
$paySn
);
}
if
(
$payResult
){
$orderConfirmUtil
=
\Order\OrderConfirmUtil
::
getInstance
();
$return
=
$orderConfirmUtil
->
updateOrderToPayed
(
array
(
'paySn'
=>
$paySn
,
'pay_type'
=>
$oldOrderPay
[
'pay_type'
]));
if
(
!
$return
[
'flag'
]){
\Error\ErrorModel
::
throwException
(
$return
[
'errorCode'
]);
}
else
{
$orderList
=
$orderDao
->
getListByCon
(
array
(
'pay_sn'
=>
$data
[
'paySn'
],
'buyer_id'
=>
$memberId
));
}
}
}
$return
=
array
();
$totalOrderAmount
=
array_sum
(
array_column
(
$orderList
,
'order_amount'
));
$orderTips
=
\Our\DescribeConst
::
paySuccessTips
;
...
...
application/models/Business/Order/PaymentService.php
View file @
43dac90f
...
...
@@ -16,6 +16,7 @@ class PaymentServiceModel extends \Business\AbstractModel{
}
public
function
checkChargeData
(
$data
){
$dbName
=
\Our\DbNameConst
::
masterDBConnectName
;
if
(
!
(
$data
[
'channel'
]
&&
in_array
(
$data
[
'channel'
],
array
(
\Our\NameConst
::
wxAppChannel
,
\Our\NameConst
::
wxLiteChannel
,
\Our\NameConst
::
aliApiChannel
,
\Our\NameConst
::
qqAppChannel
)))){
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
wrongChannelForPay
);
}
...
...
@@ -27,6 +28,22 @@ class PaymentServiceModel extends \Business\AbstractModel{
if
(
!
$order
){
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
noOrderWaitToPay
);
}
$orderPayModel
=
\DAO\Order\OrderPayModel
::
getInstance
(
$dbName
);
$paySn
=
$data
[
'paySn'
];
$channel
=
$data
[
'channel'
];
if
(
$channel
==
\Our\NameConst
::
wxLiteChannel
){
$pay_type
=
\Our\ApiConst
::
wxLitePayType
;
}
else
if
(
$channel
==
\Our\NameConst
::
qqAppChannel
){
$pay_type
=
\Our\ApiConst
::
qqPayType
;
}
else
if
(
$channel
==
\Our\NameConst
::
aliApiChannel
){
$pay_type
=
\Our\ApiConst
::
aliPayType
;
}
else
{
$pay_type
=
\Our\ApiConst
::
wxAppPayType
;
}
$resultOrderPay
=
$orderPayModel
->
update
(
array
(
'pay_type'
=>
$pay_type
),
array
(
'pay_sn'
=>
$paySn
));
if
(
!
$resultOrderPay
){
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
payTypeUpdateError
);
}
}
public
function
updateOrderToPayedWxLite
(){
...
...
application/models/Error/CodeConfig.php
View file @
43dac90f
...
...
@@ -323,6 +323,7 @@ class CodeConfigModel
const
refundMoneyError
=
300142
;
const
refundWriteError
=
300143
;
const
beyondRecieverTime
=
300144
;
const
payTypeUpdateError
=
30145
;
//店铺相关错误码
//商品分类
...
...
@@ -828,6 +829,7 @@ class CodeConfigModel
self
::
refundMoneyError
=>
'退款失败'
,
self
::
refundWriteError
=>
'退款表写入失败'
,
self
::
beyondRecieverTime
=>
'设置收货时间不能早于当前时间'
,
self
::
payTypeUpdateError
=>
'更新支付类型失败'
,
//销售员
self
::
emptySaleGoodsId
=>
'商品id不能为空'
,
self
::
emptySaleGoods
=>
'销售商品不存在'
,
...
...
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