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
1202b8c2
Commit
1202b8c2
authored
Sep 04, 2018
by
wwccw0591
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pc
parent
49c4b5c5
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
133 additions
and
111 deletions
+133
-111
AopClient.php
application/library/Alipay/aop/AopClient.php
+15
-15
SignData.php
application/library/Alipay/aop/SignData.php
+2
-0
LtLogger.php
...ation/library/Alipay/lotusphp_runtime/Logger/LtLogger.php
+0
-0
Push.php
application/library/Our/Push.php
+10
-0
Alipay.php
application/library/Payment/Alipay.php
+2
-2
WxPay.php
application/library/Payment/WxPay.php
+3
-3
OrderService.php
application/models/Business/Order/OrderService.php
+86
-87
news_server.php
scripts/crontab/push/news_server.php
+15
-4
No files found.
application/library/Alipay/aop/AopClient.php
View file @
1202b8c2
...
@@ -2,7 +2,9 @@
...
@@ -2,7 +2,9 @@
namespace
Alipay\aop
;
namespace
Alipay\aop
;
require_once
'AopEncrypt.php'
;
require_once
'AopEncrypt.php'
;
require_once
'SignData.php'
;
$libaryUrl
=
\Bootstrap
::
getUrlIniConfig
(
'libary'
);
require_once
(
$libaryUrl
.
'/Alipay/lotusphp_runtime/Logger/LtLogger.php'
);
class
AopClient
{
class
AopClient
{
//应用ID
//应用ID
public
$appId
;
public
$appId
;
...
@@ -230,14 +232,12 @@ class AopClient {
...
@@ -230,14 +232,12 @@ class AopClient {
$reponse
=
curl_exec
(
$ch
);
$reponse
=
curl_exec
(
$ch
);
if
(
curl_errno
(
$ch
))
{
if
(
curl_errno
(
$ch
))
{
throw
new
\Exception
(
curl_error
(
$ch
),
0
);
throw
new
Exception
(
curl_error
(
$ch
),
0
);
}
else
{
}
else
{
$httpStatusCode
=
curl_getinfo
(
$ch
,
CURLINFO_HTTP_CODE
);
$httpStatusCode
=
curl_getinfo
(
$ch
,
CURLINFO_HTTP_CODE
);
if
(
200
!==
$httpStatusCode
)
{
if
(
200
!==
$httpStatusCode
)
{
throw
new
Exception
(
$reponse
,
$httpStatusCode
);
throw
new
\
Exception
(
$reponse
,
$httpStatusCode
);
}
}
}
}
...
@@ -253,7 +253,7 @@ class AopClient {
...
@@ -253,7 +253,7 @@ class AopClient {
protected
function
logCommunicationError
(
$apiName
,
$requestUrl
,
$errorCode
,
$responseTxt
)
{
protected
function
logCommunicationError
(
$apiName
,
$requestUrl
,
$errorCode
,
$responseTxt
)
{
$localIp
=
isset
(
$_SERVER
[
"SERVER_ADDR"
])
?
$_SERVER
[
"SERVER_ADDR"
]
:
"CLI"
;
$localIp
=
isset
(
$_SERVER
[
"SERVER_ADDR"
])
?
$_SERVER
[
"SERVER_ADDR"
]
:
"CLI"
;
$logger
=
new
LtLogger
;
$logger
=
new
\LtLogger
()
;
$logger
->
conf
[
"log_file"
]
=
rtrim
(
AOP_SDK_WORK_DIR
,
'\\/'
)
.
'/'
.
"logs/aop_comm_err_"
.
$this
->
appId
.
"_"
.
date
(
"Y-m-d"
)
.
".log"
;
$logger
->
conf
[
"log_file"
]
=
rtrim
(
AOP_SDK_WORK_DIR
,
'\\/'
)
.
'/'
.
"logs/aop_comm_err_"
.
$this
->
appId
.
"_"
.
date
(
"Y-m-d"
)
.
".log"
;
$logger
->
conf
[
"separator"
]
=
"^_^"
;
$logger
->
conf
[
"separator"
]
=
"^_^"
;
$logData
=
array
(
$logData
=
array
(
...
@@ -475,17 +475,17 @@ class AopClient {
...
@@ -475,17 +475,17 @@ class AopClient {
if
(
$this
->
checkEmpty
(
$apiParams
[
'biz_content'
]))
{
if
(
$this
->
checkEmpty
(
$apiParams
[
'biz_content'
]))
{
throw
new
Exception
(
" api request Fail! The reason : encrypt request is not supperted!"
);
throw
new
\
Exception
(
" api request Fail! The reason : encrypt request is not supperted!"
);
}
}
if
(
$this
->
checkEmpty
(
$this
->
encryptKey
)
||
$this
->
checkEmpty
(
$this
->
encryptType
))
{
if
(
$this
->
checkEmpty
(
$this
->
encryptKey
)
||
$this
->
checkEmpty
(
$this
->
encryptType
))
{
throw
new
Exception
(
" encryptType and encryptKey must not null! "
);
throw
new
\
Exception
(
" encryptType and encryptKey must not null! "
);
}
}
if
(
"AES"
!=
$this
->
encryptType
)
{
if
(
"AES"
!=
$this
->
encryptType
)
{
throw
new
Exception
(
"加密类型只支持AES"
);
throw
new
\
Exception
(
"加密类型只支持AES"
);
}
}
// 执行加密
// 执行加密
...
@@ -510,7 +510,7 @@ class AopClient {
...
@@ -510,7 +510,7 @@ class AopClient {
//发起HTTP请求
//发起HTTP请求
try
{
try
{
$resp
=
$this
->
curl
(
$requestUrl
,
$apiParams
);
$resp
=
$this
->
curl
(
$requestUrl
,
$apiParams
);
}
catch
(
Exception
$e
)
{
}
catch
(
\
Exception
$e
)
{
$this
->
logCommunicationError
(
$sysParams
[
"method"
],
$requestUrl
,
"HTTP_ERROR_"
.
$e
->
getCode
(),
$e
->
getMessage
());
$this
->
logCommunicationError
(
$sysParams
[
"method"
],
$requestUrl
,
"HTTP_ERROR_"
.
$e
->
getCode
(),
$e
->
getMessage
());
return
false
;
return
false
;
...
@@ -1014,7 +1014,7 @@ class AopClient {
...
@@ -1014,7 +1014,7 @@ class AopClient {
* @param $signData
* @param $signData
* @param $resp
* @param $resp
* @param $respObject
* @param $respObject
* @throws Exception
* @throws
\
Exception
*/
*/
public
function
checkResponseSign
(
$request
,
$signData
,
$resp
,
$respObject
)
{
public
function
checkResponseSign
(
$request
,
$signData
,
$resp
,
$respObject
)
{
...
@@ -1023,7 +1023,7 @@ class AopClient {
...
@@ -1023,7 +1023,7 @@ class AopClient {
if
(
$signData
==
null
||
$this
->
checkEmpty
(
$signData
->
sign
)
||
$this
->
checkEmpty
(
$signData
->
signSourceData
))
{
if
(
$signData
==
null
||
$this
->
checkEmpty
(
$signData
->
sign
)
||
$this
->
checkEmpty
(
$signData
->
signSourceData
))
{
throw
new
Exception
(
" check sign Fail! The reason : signData is Empty"
);
throw
new
\
Exception
(
" check sign Fail! The reason : signData is Empty"
);
}
}
...
@@ -1045,12 +1045,12 @@ class AopClient {
...
@@ -1045,12 +1045,12 @@ class AopClient {
$checkResult
=
$this
->
verify
(
$signData
->
signSourceData
,
$signData
->
sign
,
$this
->
alipayPublicKey
,
$this
->
signType
);
$checkResult
=
$this
->
verify
(
$signData
->
signSourceData
,
$signData
->
sign
,
$this
->
alipayPublicKey
,
$this
->
signType
);
if
(
!
$checkResult
)
{
if
(
!
$checkResult
)
{
throw
new
Exception
(
"check sign Fail! [sign="
.
$signData
->
sign
.
", signSourceData="
.
$signData
->
signSourceData
.
"]"
);
throw
new
\
Exception
(
"check sign Fail! [sign="
.
$signData
->
sign
.
", signSourceData="
.
$signData
->
signSourceData
.
"]"
);
}
}
}
else
{
}
else
{
throw
new
Exception
(
"check sign Fail! [sign="
.
$signData
->
sign
.
", signSourceData="
.
$signData
->
signSourceData
.
"]"
);
throw
new
\
Exception
(
"check sign Fail! [sign="
.
$signData
->
sign
.
", signSourceData="
.
$signData
->
signSourceData
.
"]"
);
}
}
}
}
...
...
application/library/Alipay/aop/SignData.php
View file @
1202b8c2
<?php
<?php
namespace
Alipay\aop
;
/**
/**
* Created by PhpStorm.
* Created by PhpStorm.
* User: jiehua
* User: jiehua
...
...
application/library/Alipay/lotusphp_runtime/Logger/Logger.php
→
application/library/Alipay/lotusphp_runtime/Logger/L
tL
ogger.php
View file @
1202b8c2
File moved
application/library/Our/Push.php
View file @
1202b8c2
...
@@ -207,12 +207,21 @@ class Push
...
@@ -207,12 +207,21 @@ class Push
public
function
sendTcpMessage
()
public
function
sendTcpMessage
()
{
{
$push
=
\Yaf\Registry
::
get
(
'config'
)
->
get
(
'push'
);
$push
=
\Yaf\Registry
::
get
(
'config'
)
->
get
(
'push'
);
$conf
=
\Yaf\Registry
::
get
(
'config'
)
->
get
(
'redis.database.params'
);
if
(
$push
[
'open'
])
{
if
(
$push
[
'open'
])
{
if
(
!
empty
(
$this
->
data
)){
if
(
!
empty
(
$this
->
data
)){
$redis
=
new
\Redis
();
$redis
->
connect
(
$conf
[
'host'
],
$conf
[
'port'
]);
if
(
!
empty
(
$conf
[
'password'
])){
$redis
->
auth
(
$conf
[
'password'
]);
}
$message
[
'data'
]
=
$this
->
data
;
$message
[
'data'
]
=
$this
->
data
;
$message
[
'uid'
]
=
!
empty
(
$this
->
uid
)
?
$this
->
uid
:
ApiConst
::
zero
;
$message
[
'uid'
]
=
!
empty
(
$this
->
uid
)
?
$this
->
uid
:
ApiConst
::
zero
;
// $message['data']=array_slice($message['data'],2,14);
// $message['data']=array_slice($message['data'],2,14);
$message
=
json_encode
(
$message
);
$message
=
json_encode
(
$message
);
$key
=
md5
(
$message
);
$redis
->
set
(
$key
,
$message
);
$message
=
$key
;
$message
=
$message
.
"
\r\n
"
;
$message
=
$message
.
"
\r\n
"
;
$socket
=
socket_create
(
AF_INET
,
SOCK_STREAM
,
SOL_TCP
);
$socket
=
socket_create
(
AF_INET
,
SOCK_STREAM
,
SOL_TCP
);
if
(
!@
socket_connect
(
$socket
,
$push
[
'host'
],
$push
[
'port'
]))
{
if
(
!@
socket_connect
(
$socket
,
$push
[
'host'
],
$push
[
'port'
]))
{
...
@@ -239,6 +248,7 @@ class Push
...
@@ -239,6 +248,7 @@ class Push
return
true
;
return
true
;
}
}
unset
(
$this
->
data
);
unset
(
$this
->
data
);
unset
(
$redis
);
}
}
}
else
{
}
else
{
$this
->
errorCode
=
CodeConfigModel
::
pushIsNotOpen
;
$this
->
errorCode
=
CodeConfigModel
::
pushIsNotOpen
;
...
...
application/library/Payment/Alipay.php
View file @
1202b8c2
...
@@ -62,7 +62,7 @@ class Alipay {
...
@@ -62,7 +62,7 @@ class Alipay {
}
}
public
function
refund
(
$order
){
public
function
refund
(
$order
){
$refundAmount
=
round
(
$order
[
'refundAmount'
]
/
\Our\ApiConst
::
hundred
,
\Our\ApiConst
::
two
);
$refundAmount
=
round
(
$order
[
'refundAmount'
]
/
\Our\ApiConst
::
hundred
,
\Our\ApiConst
::
two
);
if
(
APP_ENV
==
'develop'
||
APP_ENV
==
'test'
||
APP_ENV
==
'pre'
){
if
(
APP_ENV
==
'develop'
||
APP_ENV
==
'test'
||
APP_ENV
==
'pre'
||
APP_ENV
==
'ccwdevelop'
){
$refundAmount
=
0.01
;
$refundAmount
=
0.01
;
}
}
$aop
=
new
\Alipay\aop\AopClient
();
$aop
=
new
\Alipay\aop\AopClient
();
...
@@ -77,7 +77,7 @@ class Alipay {
...
@@ -77,7 +77,7 @@ class Alipay {
$outRequestNo
=
$this
->
getRandomString
(
ApiConst
::
nine
);
$outRequestNo
=
$this
->
getRandomString
(
ApiConst
::
nine
);
// require_once BASE_ROOT_PATH.'/core/payment/alipay/aop/request/AlipayTradeRefundRequest.php';
// require_once BASE_ROOT_PATH.'/core/payment/alipay/aop/request/AlipayTradeRefundRequest.php';
// //require_once 'aop/request/AlipayTradeRefundRequest.php';
// //require_once 'aop/request/AlipayTradeRefundRequest.php';
$request
=
new
\Alipay\aop\request\AlipayTrade
AppPay
Request
();
$request
=
new
\Alipay\aop\request\AlipayTrade
Refund
Request
();
$request
->
setBizContent
(
"{"
.
$request
->
setBizContent
(
"{"
.
"
\"
out_trade_no
\"
:
\"
{
$order
[
'outTradeNo'
]
}
\"
,"
.
"
\"
out_trade_no
\"
:
\"
{
$order
[
'outTradeNo'
]
}
\"
,"
.
"
\"
refund_amount
\"
:
{
$refundAmount
}
,"
.
"
\"
refund_amount
\"
:
{
$refundAmount
}
,"
.
...
...
application/library/Payment/WxPay.php
View file @
1202b8c2
...
@@ -68,15 +68,15 @@ class WxPay extends \Payment\TencentPay
...
@@ -68,15 +68,15 @@ class WxPay extends \Payment\TencentPay
{
{
$total_fee
=
intval
(
$param
[
'totalFee'
]);
$total_fee
=
intval
(
$param
[
'totalFee'
]);
$refund_fee
=
intval
(
$param
[
'refundFee'
]);
$refund_fee
=
intval
(
$param
[
'refundFee'
]);
if
(
APP_ENV
==
'develop'
||
APP_ENV
==
'test'
||
APP_ENV
==
'pre'
)
{
if
(
APP_ENV
==
'develop'
||
APP_ENV
==
'test'
||
APP_ENV
==
'pre'
||
APP_ENV
==
'ccwdevelop'
)
{
$this
->
parameters
[
'total_fee'
]
=
1
;
$this
->
parameters
[
'total_fee'
]
=
1
;
$this
->
parameters
[
'refund_fee'
]
=
1
;
$this
->
parameters
[
'refund_fee'
]
=
1
;
}
else
{
}
else
{
$this
->
parameters
[
'total_fee'
]
=
$total_fee
;
$this
->
parameters
[
'total_fee'
]
=
$total_fee
;
$this
->
parameters
[
'refund_fee'
]
=
$refund_fee
;
$this
->
parameters
[
'refund_fee'
]
=
$refund_fee
;
}
}
$this
->
parameters
[
'out_refund_no'
]
=
$param
[
'refund
_order_n
o'
];
$this
->
parameters
[
'out_refund_no'
]
=
$param
[
'refund
OrderN
o'
];
$this
->
parameters
[
'out_trade_no'
]
=
$param
[
'out
_trade_n
o'
];
$this
->
parameters
[
'out_trade_no'
]
=
$param
[
'out
TradeN
o'
];
$this
->
parameters
[
'op_user_id'
]
=
$this
->
mch_id
;
$this
->
parameters
[
'op_user_id'
]
=
$this
->
mch_id
;
$this
->
parameters
[
'nonce_str'
]
=
$this
->
createNoncestr
(
32
);
$this
->
parameters
[
'nonce_str'
]
=
$this
->
createNoncestr
(
32
);
$this
->
parameters
[
'appid'
]
=
\Our\PayConst
::
wxPayAppId
;
$this
->
parameters
[
'appid'
]
=
\Our\PayConst
::
wxPayAppId
;
...
...
application/models/Business/Order/OrderService.php
View file @
1202b8c2
...
@@ -397,22 +397,13 @@ class OrderServiceModel extends \Business\AbstractModel
...
@@ -397,22 +397,13 @@ class OrderServiceModel extends \Business\AbstractModel
public
function
changeOrderStateCancelUnconditional
(
$orderInfo
)
public
function
changeOrderStateCancelUnconditional
(
$orderInfo
)
{
{
echo
234234
;
exit
;
$orderDao
=
\DAO\Order\OrderModel
::
getInstance
(
DbNameConst
::
masterDBConnectName
);
$orderDao
=
\DAO\Order\OrderModel
::
getInstance
(
DbNameConst
::
masterDBConnectName
);
$refundReturnDao
=
\DAO\Order\RefundReturnModel
::
getInstance
(
DbNameConst
::
masterDBConnectName
);
$refundReturnDao
=
\DAO\Order\RefundReturnModel
::
getInstance
(
DbNameConst
::
masterDBConnectName
);
//$orderGoodsDao=\DAO\Order\OrderGoodsModel::getInstance(
);
$orderGoodsDao
=
\DAO\Order\OrderGoodsModel
::
getInstance
(
DbNameConst
::
masterDBConnectName
);
// $orderGoods=$orderGoodsDao->getOrderGoodsByOrderIds($orderInfo['orderId']);
// $orderGoods=$orderGoodsDao->getOrderGoodsByOrderIds($orderInfo['orderId']);
try
{
try
{
$orderId
=
$orderInfo
[
'orderId'
];
$orderId
=
$orderInfo
[
'orderId'
];
//更新订单信息
$update
=
array
();
// $updateData = array('order_state' => ORDER_STATE_CANCEL,'refund_amount'=>$orderInfo['orderAmount']);
// $update = $orderDao->update($updateData, array('order_id' => $orderId));
$update
=
true
;
if
(
!
$update
)
{
echo
'订单:'
.
json_encode
(
$orderInfo
)
.
'关闭失败!!'
.
"
\r\n
"
;
}
else
{
echo
2134234
;
exit
;
$refundSn
=
$refundReturnDao
->
getRefundsn
(
$orderInfo
[
'storeId'
]);
$refundSn
=
$refundReturnDao
->
getRefundsn
(
$orderInfo
[
'storeId'
]);
//生成退款记录
//生成退款记录
$update
[
'order_id'
]
=
$orderInfo
[
'orderId'
];
$update
[
'order_id'
]
=
$orderInfo
[
'orderId'
];
...
@@ -433,43 +424,42 @@ class OrderServiceModel extends \Business\AbstractModel
...
@@ -433,43 +424,42 @@ class OrderServiceModel extends \Business\AbstractModel
$update
[
'reason_info'
]
=
'用户付款'
.
$waitDiff
.
'分钟内,店铺未接单,自动取消订单'
;
$update
[
'reason_info'
]
=
'用户付款'
.
$waitDiff
.
'分钟内,店铺未接单,自动取消订单'
;
$update
[
'buyer_message'
]
=
'用户付款'
.
$waitDiff
.
'分钟内,店铺未接单,自动取消订单'
;
$update
[
'buyer_message'
]
=
'用户付款'
.
$waitDiff
.
'分钟内,店铺未接单,自动取消订单'
;
$update
[
'is_suc_refund'
]
=
1
;
$update
[
'is_suc_refund'
]
=
1
;
echo
json_encode
(
$update
);
exit
;
$res
=
$refundReturnDao
->
addRefundReturn
(
$update
);
$res
=
$refundReturnDao
->
add
(
$update
);
if
(
!
$res
)
{
if
(
!
$res
)
{
echo
'退款记录:'
.
json_encode
(
$orderInfo
)
.
'写入失败!!'
.
"
\r\n
"
;
echo
'退款记录:'
.
json_encode
(
$orderInfo
)
.
'写入失败!!'
.
"
\r\n
"
;
}
else
{
}
else
{
$param
[
'refundOrderNo'
]
=
$refundSn
;
$param
[
'refundOrderNo'
]
=
$refundSn
;
//这个有可能多次退款的时候要变
$param
[
'outTradeNo'
]
=
$orderInfo
[
'paySn'
];
$param
[
'outTradeNo'
]
=
$orderInfo
[
'paySn'
];
$param
[
'totalFee'
]
=
$orderInfo
[
'orderAmount'
];
$param
[
'totalFee'
]
=
$orderInfo
[
'orderAmount'
];
$param
[
'refundFee'
]
=
$orderInfo
[
'orderAmount'
];
//全额退款
$param
[
'refundFee'
]
=
$orderInfo
[
'orderAmount'
];
//全额退款
$param
[
'storeId'
]
=
$orderInfo
[
'storeId'
];
$param
[
'storeId'
]
=
$orderInfo
[
'storeId'
];
$param
[
'buyerId'
]
=
$orderInfo
[
'buyerId'
];
if
(
intval
(
$orderInfo
[
'paymentType'
])
==
ApiConst
::
wxAppPayType
)
{
if
(
intval
(
$orderInfo
[
'paymentType'
])
==
ApiConst
::
wxAppPayType
)
{
$wxpay
=
\Payment\WxPay
::
getInstance
();
$wxpay
=
\Payment\WxPay
::
getInstance
();
$refund_return
=
$wxpay
->
refund
(
$param
);
$refund_return
=
$wxpay
->
refund
(
$param
);
echo
json_encode
(
$refund_return
);
if
(
!
(
$refund_return
[
'return_code'
]
==
'SUCCESS'
&&
$refund_return
[
'result_code'
]
==
'SUCCESS'
))
{
if
(
!
(
$refund_return
[
'return_code'
]
==
'SUCCESS'
&&
$refund_return
[
'result_code'
]
==
'SUCCESS'
))
{
throw
new
Exception
(
'微信退款操作执行失败!'
);
echo
'微信退款操作执行失败!'
.
$orderInfo
[
'orderId'
]
.
"
\r\n
"
;
return
false
;
}
}
}
else
if
(
intval
(
$orderInfo
[
'paymentType'
])
==
ApiConst
::
aliPayType
)
{
}
else
if
(
intval
(
$orderInfo
[
'paymentType'
])
==
ApiConst
::
alipay
)
{
$aliPay
=
\Payment\Alipay
::
getInstance
();
$aliPay
=
\Payment\Alipay
::
getInstance
();
$return
=
$aliPay
->
refund
(
$param
);
$return
=
$aliPay
->
refund
(
$param
);
echo
json_encode
(
$return
);
$resultCode
=
$return
->
code
;
$resultCode
=
$return
->
code
;
if
(
!
empty
(
$resultCode
)
&&
$resultCode
==
10000
){
if
(
!
empty
(
$resultCode
)
&&
$resultCode
==
10000
){
return
true
;
return
true
;
}
else
{
}
else
{
echo
'支付宝退款操作执行失败:'
.
$orderInfo
[
'orderId'
]
.
"
\r\n
"
;
return
false
;
return
false
;
}
}
if
(
!
(
$resultCode
&&
$resultCode
==
10000
))
{
throw
new
Exception
(
'支付宝退款操作执行失败!'
);
}
}
$orderDao
->
deleteOrderCache
(
$orderInfo
[
'buyerId'
]);
echo
$orderId
.
" 退款操作操作成功"
;
}
}
$where
[
'order_id'
]
=
$orderInfo
[
'orderId'
];
$orderGoodsUpdateData
[
'refund_state_name'
]
=
'退款成功'
;
$orderGoodsUpdateData
[
'refund_id'
]
=
1
;
$orderGoodsDao
->
update
(
$where
,
$orderGoodsUpdateData
);
echo
" 退款操作操作成功:"
.
$orderId
;
return
true
;
}
}
...
@@ -490,37 +480,46 @@ class OrderServiceModel extends \Business\AbstractModel
...
@@ -490,37 +480,46 @@ class OrderServiceModel extends \Business\AbstractModel
$beginTime
=
$beginTime
?
$beginTime
:
ApiConst
::
zero
;
$beginTime
=
$beginTime
?
$beginTime
:
ApiConst
::
zero
;
$endTime
=
TIMESTAMP
-
ApiConst
::
orderStateWaitConfirmBeyond
;
$endTime
=
TIMESTAMP
-
ApiConst
::
orderStateWaitConfirmBeyond
;
$orders
=
$orderDao
->
getMustCecelRecieveOrders
(
$beginTime
,
$endTime
,
$orderDao
->
getOrderDetailField
());
$orders
=
$orderDao
->
getMustCecelRecieveOrders
(
$beginTime
,
$endTime
,
$orderDao
->
getOrderDetailField
());
if
(
!
empty
(
$orders
))
{
if
(
!
empty
(
$orders
))
{
$orderIds
=
array_column
(
$orders
,
'orderId'
);
$orderIds
=
array_column
(
$orders
,
'orderId'
);
$orderGoods
=
$orderGoodsDao
->
getOrderGoodsByOrderIds
(
$orderIds
,
$this
->
getGoodsDetailField
());
// $orderGoods = $orderGoodsDao->getOrderGoodsByOrderIds($orderIds, $this->getGoodsDetailField());
// $storeCartsList=array();
// $storeCarts=array();
// $storeCarts['storeCarts']=array();
// foreach($orderGoods as $orderGood){
// $orderGood['type']=!empty($orderGood['goodsGroup'])? \Our\ApiConst::addBundingToCart:\Our\ApiConst::addGoodsToCart;
// $orderGood['goodsNum']=-$orderGood['goodsNum'];
// $orderGood['goodsList']=\Our\Common::isSerialized($orderGood['goodsGroup'])?unserialize($orderGood['goodsGroup']):array();
// array_push($storeCarts['storeCarts'],$orderGood);
// }
// if(!empty($storeCarts['storeCarts'])){
// array_push($storeCartsList,$storeCarts);
// }
// // $orderDao->updateNotRecieveOrders(ApiConst::orderStateWaitConfirm, ApiConst::orderStateClose, 'add_time', ApiConst::orderStateWaitConfirmBeyond, $this->orderMessageField);
// try{
// $orderConfirmUtilDao->updateGoodsStorage($storeCartsList);
// }catch(\Exception $ex){
// throw new \Exception('商品库存更新失败:'.$ex->getMessage(),$ex->getCode());
// }
// exit;
foreach
(
$orders
as
$order
)
{
foreach
(
$orders
as
$order
)
{
$orderDao
->
deleteOrderCache
(
$order
[
'buyerId'
],
$order
[
'orderId'
],
$order
[
'storeId'
]);
//更新订单信息
if
(
$order
[
'paymentTime'
]
>
ApiConst
::
zero
&&
in_array
(
$orders
[
'paymentType'
],
ArrayConst
::
orderPayTypeOnlines
))
{
$updateData
=
array
(
'order_state'
=>
ApiConst
::
orderStateClose
,
'refund_amount'
=>
$order
[
'orderAmount'
]);
$update
=
$orderDao
->
update
(
array
(
'order_id'
=>
$order
[
'orderId'
]),
$updateData
);
if
(
$update
){
if
(
$order
[
'paymentTime'
]
>
ApiConst
::
zero
&&
in_array
(
$order
[
'paymentType'
],
ArrayConst
::
orderPayTypeOnlines
))
{
$this
->
changeOrderStateCancelUnconditional
(
$order
);
$this
->
changeOrderStateCancelUnconditional
(
$order
);
}
}
}
}
$orderDao
->
deleteOrderCache
(
$order
[
'buyerId'
],
$order
[
'orderId'
],
$order
[
'storeId'
]);
}
$push
=
Push
::
getInstance
();
$push
=
Push
::
getInstance
();
$push
->
pushOrderCloseMessage
(
$orders
);
$push
->
pushOrderCloseMessage
(
$orders
);
$storeCartsList
=
array
();
$storeCarts
=
array
();
$storeCarts
[
'storeCarts'
]
=
array
();
foreach
(
$orderGoods
as
$orderGood
){
$orderGood
[
'type'
]
=!
empty
(
$orderGood
[
'goodsGroup'
])
?
\Our\ApiConst
::
addBundingToCart
:
\Our\ApiConst
::
addGoodsToCart
;
$orderGood
[
'goodsNum'
]
=-
$orderGood
[
'goodsNum'
];
$orderGood
[
'goodsList'
]
=
\Our\Common
::
isSerialized
(
$orderGood
[
'goodsGroup'
])
?
unserialize
(
$orderGood
[
'goodsGroup'
])
:
array
();
array_push
(
$storeCarts
[
'storeCarts'
],
$orderGood
);
}
if
(
!
empty
(
$storeCarts
[
'storeCarts'
])){
array_push
(
$storeCartsList
,
$storeCarts
);
}
// $orderDao->updateNotRecieveOrders(ApiConst::orderStateWaitConfirm, ApiConst::orderStateClose, 'add_time', ApiConst::orderStateWaitConfirmBeyond, $this->orderMessageField);
try
{
$orderConfirmUtilDao
->
updateGoodsStorage
(
$storeCartsList
);
}
catch
(
\Exception
$ex
){
throw
new
\Exception
(
'商品库存更新失败:'
.
$ex
->
getMessage
(),
$ex
->
getCode
());
}
}
}
file_put_contents
(
$this
->
baseDir
.
\Our\PathConst
::
orderCloseWaitRecieveOrder
,
$endTime
);
}
}
//订单任务脚本自动确认收货
//订单任务脚本自动确认收货
...
...
scripts/crontab/push/news_server.php
View file @
1202b8c2
...
@@ -188,20 +188,30 @@ $tcp_server->on('connect', function($serv, $fd) use($conf){
...
@@ -188,20 +188,30 @@ $tcp_server->on('connect', function($serv, $fd) use($conf){
*/
*/
$tcp_server
->
on
(
'receive'
,
function
(
$serv
,
$fd
,
$from_id
,
$data
)
use
(
$conf
)
{
$tcp_server
->
on
(
'receive'
,
function
(
$serv
,
$fd
,
$from_id
,
$data
)
use
(
$conf
)
{
// echo $data;
// echo $data;
$data
=
json_decode
(
$data
,
true
);
//$data = json_decode($data, true);
if
(
empty
(
$data
[
'data'
])
&&
!
isset
(
$data
[
'data'
])){
// if(empty($data['data']) && !isset($data['data'])){
// $serv->send($fd, responseJson(1,"fail", ['method' => 'receive', 'error_code' => 1, 'status' => 0]));
// $serv->close($fd);
// return;
// }
if
(
empty
(
$data
)
&&
!
isset
(
$data
)){
$serv
->
send
(
$fd
,
responseJson
(
1
,
"fail"
,
[
'method'
=>
'receive'
,
'error_code'
=>
1
,
'status'
=>
0
]));
$serv
->
send
(
$fd
,
responseJson
(
1
,
"fail"
,
[
'method'
=>
'receive'
,
'error_code'
=>
1
,
'status'
=>
0
]));
$serv
->
close
(
$fd
);
$serv
->
close
(
$fd
);
return
;
return
;
}
}
$s
=
json_encode
(
$data
[
'data'
]);
//
$s = json_encode($data['data']);
echo
$
s
;
echo
$
data
;
// 推送 存入redis、最后入库(MySQL)
// 推送 存入redis、最后入库(MySQL)
$redis
=
new
Redis
();
$redis
=
new
Redis
();
$redis
->
connect
(
$conf
[
'host'
],
$conf
[
'port'
]);
$redis
->
connect
(
$conf
[
'host'
],
$conf
[
'port'
]);
if
(
!
empty
(
$conf
[
'password'
])){
if
(
!
empty
(
$conf
[
'password'
])){
$redis
->
auth
(
$conf
[
'password'
]);
$redis
->
auth
(
$conf
[
'password'
]);
}
}
$key
=
trim
(
$data
,
"
\r\n
"
);
$data
=
$redis
->
get
(
$key
);
$redis
->
delete
(
$key
);
$data
=
json_decode
(
$data
,
true
);
if
(
true
)
{
if
(
true
)
{
$serv
->
send
(
$fd
,
responseJson
(
1
,
"success"
,
[
'method'
=>
'receive'
,
'error_code'
=>
0
,
'status'
=>
1
]));
$serv
->
send
(
$fd
,
responseJson
(
1
,
"success"
,
[
'method'
=>
'receive'
,
'error_code'
=>
0
,
'status'
=>
1
]));
$serv
->
close
(
$fd
);
$serv
->
close
(
$fd
);
...
@@ -234,6 +244,7 @@ $tcp_server->on('receive', function($serv, $fd, $from_id, $data) use($conf) {
...
@@ -234,6 +244,7 @@ $tcp_server->on('receive', function($serv, $fd, $from_id, $data) use($conf) {
}
else
{
}
else
{
$serv
->
send
(
$fd
,
responseJson
(
1
,
'fromMsg'
,
"fail"
,
[
'method'
=>
'receive'
,
'error_code'
=>
110
,
'status'
=>
0
]));
$serv
->
send
(
$fd
,
responseJson
(
1
,
'fromMsg'
,
"fail"
,
[
'method'
=>
'receive'
,
'error_code'
=>
110
,
'status'
=>
0
]));
}
}
unset
(
$redis
);
});
});
...
...
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