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
da3275ac
Commit
da3275ac
authored
Dec 04, 2018
by
zhz
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master_dev' of git.shenbd.com:qm-develop/shenbd into master_dev
parents
1ade5247
255b0fd7
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
376 additions
and
6 deletions
+376
-6
Index.php
application/controllers/Index.php
+6
-0
AreaUtil.php
application/library/Area/AreaUtil.php
+66
-0
ClientPush.php
application/library/JPush/ClientPush.php
+81
-0
ApiConst.php
application/library/Our/ApiConst.php
+7
-0
Common.php
application/library/Our/Common.php
+42
-0
NameConst.php
application/library/Our/NameConst.php
+9
-0
WxPay.php
application/library/Payment/WxPay.php
+2
-2
RefundService.php
application/models/Business/Order/RefundService.php
+5
-3
Area.php
application/models/DAO/Area.php
+3
-0
Member.php
application/models/DAO/Member.php
+5
-0
CodeConfig.php
application/models/Error/CodeConfig.php
+4
-0
Shopkeeper.php
application/modules/Client/controllers/Shopkeeper.php
+4
-1
temp.txt
public/temp.txt
+0
-0
jpushTest.php
scripts/crontab/push/jpushTest.php
+142
-0
No files found.
application/controllers/Index.php
View file @
da3275ac
...
@@ -56,6 +56,12 @@ class IndexController extends \Our\Controller_Abstract {
...
@@ -56,6 +56,12 @@ class IndexController extends \Our\Controller_Abstract {
exit
;
exit
;
}
}
public
function
testPushAction
(){
$clientPush
=
\JPush\ClientPush
::
getInstance
();
$clientPush
->
pushTest
(
array
());
exit
;
}
public
function
indexAction
()
{
public
function
indexAction
()
{
$getKey
=
$_GET
[
'key'
];
$getKey
=
$_GET
[
'key'
];
if
(
$getKey
!=
'~!@#$`1234qwert'
){
if
(
$getKey
!=
'~!@#$`1234qwert'
){
...
...
application/library/Area/AreaUtil.php
0 → 100644
View file @
da3275ac
<?php
namespace
Area
;
/**
* User: liuyuzhen
* Date: 2018/12/3
* Time: 16:52
* Description:
*/
class
AreaUtil
{
public
function
getIpCityInfo
(
$ip
=
''
){
if
(
!
$ip
){
$ip
=
\Our\Common
::
getIP
();
}
$cityData
=
\Our\Common
::
getIpCity
(
$ip
);
$provinceId
=
\Our\ApiConst
::
zero
;
$cityId
=
\Our\ApiConst
::
zero
;
switch
(
$cityData
[
'country'
]){
case
\Our\NameConst
::
China
:
if
(
$cityData
[
'region'
]){
$province
=
mb_substr
(
$cityData
[
'region'
],
0
,
2
);
$provinceObj
=
\DAO\AreaModel
::
getInstance
()
->
getOne
(
array
(
'area_deep'
=>
1
,
'area_name'
=>
array
(
'like'
,
$province
.
'%'
)),
'area_id,area_name'
);
if
(
$provinceObj
){
$provinceId
=
$provinceObj
[
'area_id'
];
$city
=
trim
(
$cityData
[
'city'
]);
if
(
$city
){
$cityObj
=
\DAO\AreaModel
::
getInstance
()
->
getOne
(
array
(
'area_parent_id'
=>
$provinceId
,
'area_name'
=>
array
(
'like'
,
$city
.
'%'
)),
'area_id,area_name'
);
$cityObj
&&
$cityId
=
$cityObj
[
'area_id'
];
}
}
}
break
;
case
\Our\NameConst
::
Macao
:
$provinceId
=
\Our\ApiConst
::
MacaoCode
;
break
;
case
\Our\NameConst
::
Hongkong
:
$provinceId
=
\Our\ApiConst
::
HongkongCode
;
break
;
case
\Our\NameConst
::
Taiwan
:
$provinceId
=
\Our\ApiConst
::
TaiwanCode
;
break
;
default
:
$provinceId
=
\Our\ApiConst
::
otherCountryCode
;
break
;
}
return
array
(
'member_provinceid'
=>
$provinceId
,
'member_cityid'
=>
$cityId
);
}
/**
* 类实例
*
*/
private
static
$_instance
=
null
;
/**
* 单例模式获取类实例
*
*/
public
static
function
getInstance
()
{
if
(
!
(
self
::
$_instance
instanceof
self
))
{
self
::
$_instance
=
new
self
();
}
return
self
::
$_instance
;
}
}
\ No newline at end of file
application/library/JPush/ClientPush.php
View file @
da3275ac
...
@@ -62,6 +62,87 @@ class ClientPush
...
@@ -62,6 +62,87 @@ class ClientPush
}
}
return
$messageContent
;
return
$messageContent
;
}
}
public
function
pushTest
(
$pushData
)
{
// $pushFlag=(APP_ENV=='product' || APP_ENV=='productone')?true:false;
$pushFlag
=
$_POST
[
'pushFlag'
];
$pushFlag
=
$pushFlag
?
true
:
false
;
// echo json_encode($pushData);
$title
=
$this
->
getMessageType
(
$pushData
[
'fromType'
]);
$messageContent
=
$this
->
getMessageContent
(
$pushData
[
'message'
]);
$pushObject
=
array
(
'id'
=>
433
,
'memberName'
=>
'abc'
);
$messageContent
=
"testMessage"
;
$title
=
'tesetTitle'
;
$pushData
[
'toId'
]
=
$_POST
[
'toId'
];
// echo $pushData['toId'];
try
{
$response
=
$this
->
client
->
push
()
->
setPlatform
(
'all'
)
// 一般情况下,关于 audience 的设置只需要调用 addAlias、addTag、addTagAnd 或 addRegistrationId
// 这四个方法中的某一个即可,这里仅作为示例,当然全部调用也可以,多项 audience 调用表示其结果的交集
// 即是说一般情况下,下面三个方法和没有列出的 addTagAnd 一共四个,只适用一个便可满足大多数的场景需求
->
addAlias
((
string
)
$pushData
[
'toId'
])
// ->addTag(array($pushData['toId'], 'tag2'))
//->addRegistrationId($pushData['toId'])
->
setNotificationAlert
(
$title
)
->
iosNotification
(
$messageContent
,
array
(
'sound'
=>
'sound.caf'
,
// 'badge' => '+1',
// 'content-available' => true,
// 'mutable-content' => true,
'category'
=>
'shenbd'
,
'extras'
=>
$pushData
,
))
->
androidNotification
(
$messageContent
,
array
(
'title'
=>
$title
,
// 'builder_id' => 2,
'extras'
=>
$pushData
,
))
->
message
(
$messageContent
,
array
(
'title'
=>
$title
,
'content_type'
=>
$pushData
[
'message'
][
'type'
],
'extras'
=>
$pushData
,
))
->
options
(
array
(
// sendno: 表示推送序号,纯粹用来作为 API 调用标识,
// API 返回时被原样返回,以方便 API 调用方匹配请求与返回
// 这里设置为 100 仅作为示例
// 'sendno' => 100,
// time_to_live: 表示离线消息保留时长(秒),
// 推送当前用户不在线时,为该用户保留多长时间的离线消息,以便其上线时再次推送。
// 默认 86400 (1 天),最长 10 天。设置为 0 表示不保留离线消息,只有推送当前在线的用户可以收到
// 这里设置为 1 仅作为示例
// 'time_to_live' => 1,
// apns_production: 表示APNs是否生产环境,
// True 表示推送生产环境,False 表示要推送开发环境;如果不指定则默认为推送生产环境
'apns_production'
=>
$pushFlag
,
// big_push_duration: 表示定速推送时长(分钟),又名缓慢推送,把原本尽可能快的推送速度,降低下来,
// 给定的 n 分钟内,均匀地向这次推送的目标用户推送。最大值为1400.未设置则不是定速推送
// 这里设置为 1 仅作为示例
// 'big_push_duration' => 1
))
->
send
();
$response
[
'memberId'
]
=
$_POST
[
'toId'
];
echo
json_encode
(
$response
);
}
catch
(
\JPush\Exceptions\APIConnectionException
$e
)
{
// try something here
print
$e
;
}
catch
(
\JPush\Exceptions\APIRequestException
$e
)
{
// try something here
print
$e
;
}
}
public
function
push
(
$pushData
)
public
function
push
(
$pushData
)
{
{
// $pushFlag=(APP_ENV=='product' || APP_ENV=='productone')?true:false;
// $pushFlag=(APP_ENV=='product' || APP_ENV=='productone')?true:false;
...
...
application/library/Our/ApiConst.php
View file @
da3275ac
...
@@ -462,6 +462,13 @@ class ApiConst
...
@@ -462,6 +462,13 @@ class ApiConst
const
arrBegin
=
0
;
const
arrBegin
=
0
;
const
TaiwanCode
=
32
;
const
HongkongCode
=
33
;
const
MacaoCode
=
34
;
const
otherCountryCode
=
35
;
...
...
application/library/Our/Common.php
View file @
da3275ac
...
@@ -576,4 +576,46 @@ class Common
...
@@ -576,4 +576,46 @@ class Common
return
$price_format
;
return
$price_format
;
}
}
/**
* 获取当前访问用户地址
* @return string
*/
public
static
function
getIP
(){
static
$realip
;
if
(
isset
(
$_SERVER
)){
if
(
isset
(
$_SERVER
[
"HTTP_X_FORWARDED_FOR"
])){
$realip
=
$_SERVER
[
"HTTP_X_FORWARDED_FOR"
];
}
else
if
(
isset
(
$_SERVER
[
"HTTP_CLIENT_IP"
]))
{
$realip
=
$_SERVER
[
"HTTP_CLIENT_IP"
];
}
else
{
$realip
=
$_SERVER
[
"REMOTE_ADDR"
];
}
}
else
{
if
(
getenv
(
"HTTP_X_FORWARDED_FOR"
)){
$realip
=
getenv
(
"HTTP_X_FORWARDED_FOR"
);
}
else
if
(
getenv
(
"HTTP_CLIENT_IP"
))
{
$realip
=
getenv
(
"HTTP_CLIENT_IP"
);
}
else
{
$realip
=
getenv
(
"REMOTE_ADDR"
);
}
}
return
$realip
;
}
/**
* 获取用户所在地区
* @param $ip
* @return array|bool
*/
public
static
function
getIpCity
(
$ip
){
$url
=
"http://ip.taobao.com/service/getIpInfo.php?ip="
.
$ip
;
$ip
=
json_decode
(
file_get_contents
(
$url
));
if
((
string
)
$ip
->
code
==
'1'
){
return
false
;
}
$data
=
(
array
)
$ip
->
data
;
return
$data
;
}
}
}
application/library/Our/NameConst.php
View file @
da3275ac
...
@@ -185,6 +185,15 @@ class NameConst {
...
@@ -185,6 +185,15 @@ class NameConst {
const
bySeller
=
'bySeller'
;
const
bySeller
=
'bySeller'
;
const
bySelf
=
'bySelf'
;
const
bySelf
=
'bySelf'
;
const
China
=
'中国'
;
const
Hongkong
=
'香港'
;
const
Taiwan
=
'台湾'
;
const
Macao
=
'澳门'
;
const
otherCountry
=
'海外'
;
}
}
?>
?>
\ No newline at end of file
application/library/Payment/WxPay.php
View file @
da3275ac
...
@@ -61,9 +61,9 @@ class WxPay extends \Payment\TencentPay
...
@@ -61,9 +61,9 @@ class WxPay extends \Payment\TencentPay
public
function
refund
(
$param
){
public
function
refund
(
$param
){
if
(
$param
[
'subMchId'
]){
if
(
$param
[
'subMchId'
]){
$this
->
serviceRefund
(
$param
);
return
$this
->
serviceRefund
(
$param
);
}
else
{
}
else
{
$this
->
commonRefund
(
$param
);
return
$this
->
commonRefund
(
$param
);
}
}
}
}
...
...
application/models/Business/Order/RefundService.php
View file @
da3275ac
...
@@ -136,8 +136,8 @@ class RefundServiceModel extends \Business\AbstractModel
...
@@ -136,8 +136,8 @@ class RefundServiceModel extends \Business\AbstractModel
}
}
$refundReturnDao
->
db
->
doTransaction
();
$refundReturnDao
->
db
->
doTransaction
();
$state
=
$refundReturnDao
->
editRefundReturn
(
$whereRefund
,
$refund_array
);
$state
=
$refundReturnDao
->
editRefundReturn
(
$whereRefund
,
$refund_array
);
if
(
$state
){
//退款记录成功
if
(
$state
){
//退款记录成功
//记录操作日志
//记录操作日志
$sellerLogDAO
=
\DAO\SellerLogModel
::
getInstance
();
$sellerLogDAO
=
\DAO\SellerLogModel
::
getInstance
();
$sellerLogDAO
->
record
(
'退货确认收货,退货编号:'
.
$refund
[
'refund_sn'
],
array
(
'seller_id'
=>
$sellerId
,
'seller_name'
=>
$sellerName
,
'store_id'
=>
$storeId
));
$sellerLogDAO
->
record
(
'退货确认收货,退货编号:'
.
$refund
[
'refund_sn'
],
array
(
'seller_id'
=>
$sellerId
,
'seller_name'
=>
$sellerName
,
'store_id'
=>
$storeId
));
...
@@ -159,6 +159,7 @@ class RefundServiceModel extends \Business\AbstractModel
...
@@ -159,6 +159,7 @@ class RefundServiceModel extends \Business\AbstractModel
if
(
!
in_array
(
$payment_type
,
array
(
0
,
2
)))
{
if
(
!
in_array
(
$payment_type
,
array
(
0
,
2
)))
{
$state
=
$refundReturnDao
->
storeRefund
(
array_merge
(
$order_info
,
array
(
'refund_order_no'
=>
$refund
[
'order_sn'
],
'refund_amount'
=>
$refund
[
'refund_amount'
])));
$state
=
$refundReturnDao
->
storeRefund
(
array_merge
(
$order_info
,
array
(
'refund_order_no'
=>
$refund
[
'order_sn'
],
'refund_amount'
=>
$refund
[
'refund_amount'
])));
if
(
!
$state
)
{
if
(
!
$state
)
{
ErrorModel
::
throwException
(
CodeConfigModel
::
refundMoneyError
);
//throw new Exception('更新订单信息失败');
//throw new Exception('更新订单信息失败');
$refundReturnDao
->
db
->
doRollback
();
$refundReturnDao
->
db
->
doRollback
();
return
false
;
return
false
;
...
@@ -168,6 +169,7 @@ class RefundServiceModel extends \Business\AbstractModel
...
@@ -168,6 +169,7 @@ class RefundServiceModel extends \Business\AbstractModel
$refundUpdate
=
array
(
'is_suc_refund'
=>
1
,
'gmt_update'
=>
TIMESTAMP
,
'refund_state'
=>
3
);
$refundUpdate
=
array
(
'is_suc_refund'
=>
1
,
'gmt_update'
=>
TIMESTAMP
,
'refund_state'
=>
3
);
$res
=
$refundReturnDao
->
update
(
array
(
'refund_id'
=>
$refund
[
'refund_id'
]),
$refundUpdate
);
$res
=
$refundReturnDao
->
update
(
array
(
'refund_id'
=>
$refund
[
'refund_id'
]),
$refundUpdate
);
if
(
!
$res
)
{
if
(
!
$res
)
{
ErrorModel
::
throwException
(
CodeConfigModel
::
refundWriteError
);
$refundReturnDao
->
db
->
doRollback
();
$refundReturnDao
->
db
->
doRollback
();
// showDialog('退款成功,退款表写入失败,请联系工作人员!',$reload,'error');
// showDialog('退款成功,退款表写入失败,请联系工作人员!',$reload,'error');
return
false
;
return
false
;
...
@@ -184,6 +186,8 @@ class RefundServiceModel extends \Business\AbstractModel
...
@@ -184,6 +186,8 @@ class RefundServiceModel extends \Business\AbstractModel
$refundReturnDao
->
deleteRefundCache
(
$refund
[
'buyer_id'
],
$refund
[
'refund_id'
]);
$refundReturnDao
->
deleteRefundCache
(
$refund
[
'buyer_id'
],
$refund
[
'refund_id'
]);
$orderDao
->
deleteOrderCache
(
$refund
[
'buyer_id'
],
$refund
[
'order_id'
],
$refund
[
'store_id'
]);
$orderDao
->
deleteOrderCache
(
$refund
[
'buyer_id'
],
$refund
[
'order_id'
],
$refund
[
'store_id'
]);
$storeDAO
->
deleteStoreRefundCache
(
$refund
[
'store_id'
],
$refund
[
'order_id'
]);
$storeDAO
->
deleteStoreRefundCache
(
$refund
[
'store_id'
],
$refund
[
'order_id'
]);
$orderService
=
\Business\Order\OrderServiceModel
::
getInstance
();
$orderService
->
updateOrderGoodsStoregeByOrderIds
(
$refund
[
'order_id'
]);
$refundReturnDao
->
db
->
doCommit
();
$refundReturnDao
->
db
->
doCommit
();
$push
=
\Our\Push
::
getInstance
();
$push
=
\Our\Push
::
getInstance
();
$pushData
=
array
(
'storeId'
=>
$storeId
,
$pushData
=
array
(
'storeId'
=>
$storeId
,
...
@@ -286,8 +290,6 @@ class RefundServiceModel extends \Business\AbstractModel
...
@@ -286,8 +290,6 @@ class RefundServiceModel extends \Business\AbstractModel
if
(
$refund_array
[
'seller_state'
]
==
'2'
&&
!
$isGiveUp
)
{
if
(
$refund_array
[
'seller_state'
]
==
'2'
&&
!
$isGiveUp
)
{
$refund_array
[
'return_type'
]
=
'2'
;
//退货类型:1为不用退货,2为需要退货
$refund_array
[
'return_type'
]
=
'2'
;
//退货类型:1为不用退货,2为需要退货
$refund_array
[
'goods_state'
]
=
2
;
$refund_array
[
'goods_state'
]
=
2
;
$orderService
=
\Business\Order\OrderServiceModel
::
getInstance
();
$orderService
->
updateOrderGoodsStoregeByOrderIds
(
$return
[
'order_id'
]);
}
elseif
(
$refund_array
[
'seller_state'
]
==
'3'
)
{
}
elseif
(
$refund_array
[
'seller_state'
]
==
'3'
)
{
$refund_array
[
'refund_state'
]
=
'3'
;
//状态:1为处理中,2为待管理员处理,3为已完成
$refund_array
[
'refund_state'
]
=
'3'
;
//状态:1为处理中,2为待管理员处理,3为已完成
...
...
application/models/DAO/Area.php
View file @
da3275ac
...
@@ -28,6 +28,9 @@ class AreaModel extends \DAO\AbstractModel {
...
@@ -28,6 +28,9 @@ class AreaModel extends \DAO\AbstractModel {
public
function
getOne
(
$where
,
$field
=
\Our\NameConst
::
allField
){
public
function
getOne
(
$where
,
$field
=
\Our\NameConst
::
allField
){
$this
->
setDb
(
$this
->
dbName
);
$this
->
setDb
(
$this
->
dbName
);
if
(
is_array
(
$where
)){
$where
=
$this
->
db
->
getSqlWhereByArray
(
$where
);
}
return
$this
->
db
->
select
(
$field
)
->
from
(
$this
->
_tableName
)
->
where
(
$where
)
->
fetchOne
();
return
$this
->
db
->
select
(
$field
)
->
from
(
$this
->
_tableName
)
->
where
(
$where
)
->
fetchOne
();
}
}
...
...
application/models/DAO/Member.php
View file @
da3275ac
...
@@ -158,6 +158,11 @@ class MemberModel extends \DAO\AbstractModel
...
@@ -158,6 +158,11 @@ class MemberModel extends \DAO\AbstractModel
{
{
// $this->setDb(\Our\DbNameConst::masterDBConnectName);
// $this->setDb(\Our\DbNameConst::masterDBConnectName);
// $result = $this->db->insert($this->_tableName)->rows($data)->execute();
// $result = $this->db->insert($this->_tableName)->rows($data)->execute();
$cityCode
=
\Area\AreaUtil
::
getInstance
()
->
getIpCityInfo
();
if
(
is_array
(
$cityCode
)){
$data
=
array_merge
(
$data
,
$cityCode
);
}
$result
=
$this
->
add
(
$data
);
$result
=
$this
->
add
(
$data
);
if
(
$result
)
{
if
(
$result
)
{
$memberDb0Redis
=
\Redis\Db0\MemberRedisModel
::
getInstance
();
$memberDb0Redis
=
\Redis\Db0\MemberRedisModel
::
getInstance
();
...
...
application/models/Error/CodeConfig.php
View file @
da3275ac
...
@@ -320,6 +320,8 @@ class CodeConfigModel
...
@@ -320,6 +320,8 @@ class CodeConfigModel
const
wrongRefundState
=
300139
;
const
wrongRefundState
=
300139
;
const
updateIsRefundFail
=
300140
;
const
updateIsRefundFail
=
300140
;
const
updateRefundStateNameFail
=
300141
;
const
updateRefundStateNameFail
=
300141
;
const
refundMoneyError
=
300142
;
const
refundWriteError
=
300143
;
//店铺相关错误码
//店铺相关错误码
//商品分类
//商品分类
...
@@ -821,6 +823,8 @@ class CodeConfigModel
...
@@ -821,6 +823,8 @@ class CodeConfigModel
self
::
wrongRefundState
=>
'订单状态有误'
,
self
::
wrongRefundState
=>
'订单状态有误'
,
self
::
updateIsRefundFail
=>
'更新is_refund失败'
,
self
::
updateIsRefundFail
=>
'更新is_refund失败'
,
self
::
updateRefundStateNameFail
=>
'更新order表refund_state_name失败'
,
self
::
updateRefundStateNameFail
=>
'更新order表refund_state_name失败'
,
self
::
refundMoneyError
=>
'退款失败'
,
self
::
refundWriteError
=>
'退款表写入失败'
,
//销售员
//销售员
self
::
emptySaleGoodsId
=>
'商品id不能为空'
,
self
::
emptySaleGoodsId
=>
'商品id不能为空'
,
self
::
emptySaleGoods
=>
'销售商品不存在'
,
self
::
emptySaleGoods
=>
'销售商品不存在'
,
...
...
application/modules/Client/controllers/Shopkeeper.php
View file @
da3275ac
...
@@ -294,7 +294,10 @@ class ShopkeeperController extends \Our\Controller_AbstractClient {
...
@@ -294,7 +294,10 @@ class ShopkeeperController extends \Our\Controller_AbstractClient {
$refundService
=
\Business\Order\RefundServiceModel
::
getInstance
();
$refundService
=
\Business\Order\RefundServiceModel
::
getInstance
();
$goodsState
=
intval
(
$this
->
req
[
'data'
][
'goodsState'
]);
$goodsState
=
intval
(
$this
->
req
[
'data'
][
'goodsState'
]);
$res
=
$refundService
->
receive
(
$this
->
storeId
,
$this
->
sellerId
,
$this
->
sellerName
,
$refundId
,
$goodsState
);
$res
=
$refundService
->
receive
(
$this
->
storeId
,
$this
->
sellerId
,
$this
->
sellerName
,
$refundId
,
$goodsState
);
$this
->
success
(
$res
);
if
(
$res
){
$this
->
success
(
$res
);
}
}
}
...
...
public/temp.txt
0 → 100644
View file @
da3275ac
scripts/crontab/push/jpushTest.php
0 → 100644
View file @
da3275ac
<?php
/**
* 推送10秒推送一次
* 推送10秒推送一次
*
* @author chenjiebin <sjlinyu@qq.com>
*/
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
cliOrderClose
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
autoPushMessage
(){
$conf
=
\Yaf\Registry
::
get
(
'config'
)
->
get
(
'redis.database.params'
);
$redis
=
new
\Redis
();
$redis
->
pconnect
(
$conf
[
'host'
],
$conf
[
'port'
]);
if
(
!
empty
(
$conf
[
'password'
]))
{
$redis
->
auth
(
$conf
[
'password'
]);
}
$clientPush
=
\JPush\ClientPush
::
getInstance
();
$clientPush
->
pushTest
(
array
());
exit
;
$memberCenterServiceDao
=
\Business\User\MemberCenterServiceModel
::
getInstance
();
//$messageService=\DAO\MessageHistoryModel::getInstance();
while
(
$pushData
=
$redis
->
rPop
(
'push_center'
)){
$addData
=
unserialize
(
$pushData
);
$addData
[
'message'
]
=
unserialize
(
$addData
[
'message'
]);
$res
=
$memberCenterServiceDao
->
getMessageSet
(
$addData
[
'toId'
]);
if
(
$res
[
'canPush'
]
!=
\Our\ApiConst
::
one
){
continue
;
}
// else{
// if(!empty($res['timeDiff'])){
// $timeArr=explode('-',$res['timeDiff']);
// if(!empty($timeArr)){v
// if(\Our\Common::isCurentTimeInSection($timeArr[0],$timeArr[1])){
// continue;
// }
// }
// }
//
// }
$clientPush
->
push
(
$addData
);
}
$redis
->
close
();
}
protected
function
autoPushClient
(){
$push
=
\Our\Push
::
getInstance
();
while
(
$pushData
=
\Our\RedisHelper
::
lpop
(
'client_push'
)){
$push
->
addOneToClient
(
$pushData
);
}
$goodsCommonService
=
\Business\Goods\GoodsCommonServiceModel
::
getInstance
();
$storesBase
=
$goodsCommonService
->
getAlertGoods
();
if
(
$storesBase
){
$storesIds
=
array_column
(
$storesBase
,
'storeId'
);
$stores
=
$goodsCommonService
->
getGoodsCount
(
$storesIds
);
if
(
!
empty
(
$stores
)){
foreach
(
$stores
as
$store
){
$addData
=
array
(
'storeId'
=>
$store
[
'storeId'
],
'type'
=>
\Our\ApiConst
::
messageGoodsAlert
,
'op'
=>
\Our\NameConst
::
set
,
'alertCount'
=>
$store
[
'count'
],
'params'
=>
array
());
$push
->
addOneToClient
(
$addData
);
}
}
}
$push
->
sendTcpMessage
();
}
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
(
'push'
);
if
(
!
$this
->
mkdirs
(
$lockDir
)){
echo
'****create dir fail ****'
;
exit
;
}
$this
->
lockFileName
=
$lockDir
.
DS
.
'jpush.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
->
autoPushMessage
();
echo
date
(
'Y-m-d H:i:s'
,
TIMESTAMP
)
.
'消息推送成功'
.
"
\r\n
"
;
$this
->
autoPushClient
();
echo
date
(
'Y-m-d H:i:s'
,
TIMESTAMP
)
.
'客户端消息推送成功'
.
"
\r\n
"
;
}
}
$oCli
=
new
cliOrderClose
(
TRUE
);
EXIT
;
?>
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