mirror of
https://gitee.com/ShopeX/OMS
synced 2026-03-30 13:05:34 +08:00
117 lines
3.3 KiB
PHP
117 lines
3.3 KiB
PHP
<?php
|
|
/**
|
|
* Copyright 2012-2026 ShopeX (https://www.shopex.cn)
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
|
|
class ome_ctl_admin_service_taobao extends desktop_controller
|
|
{
|
|
|
|
public $expireDay = 7; //session过期提醒设置
|
|
|
|
/**
|
|
* @验证session是否过期
|
|
* @access public
|
|
* @param void
|
|
* @return void/json
|
|
*/
|
|
public function validity() {
|
|
$shopInfo = $this->getTaoBaoShop();
|
|
if (count($shopInfo)>0) {
|
|
echo json_encode(array('has_expire'=>true));
|
|
}else{
|
|
return array();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @根据session日期期限弹窗显示的提示信息页
|
|
* @access public
|
|
* @param void
|
|
* @return void
|
|
*/
|
|
public function alert()
|
|
{
|
|
$shopInfo = $this->getTaoBaoShop();
|
|
$this->pagedata['shopInfo'] = $shopInfo;
|
|
$this->display('admin/service/taobaoalert.html');
|
|
}
|
|
|
|
/**
|
|
* 获取淘宝session过期的网店
|
|
*
|
|
* @param void
|
|
* @return void
|
|
* @author
|
|
**/
|
|
public function getTaoBaoShop()
|
|
{
|
|
$shopMdl = app::get('ome')->model('shop');
|
|
$shopInfo = $shopMdl->getList('shop_id,shop_bn,shop_type,name,node_id,addon,node_type',array('node_type'=>'taobao','node_id|nothan'=>''));
|
|
if(count($shopInfo)<1){
|
|
return array();
|
|
}
|
|
foreach ($shopInfo as $key => $shop) {
|
|
$expireDay = $this->getSessionDays($shop);
|
|
if($expireDay>$this->expireDay || $expireDay == 'no_expire_time' ){
|
|
unset($shopInfo[$key]);
|
|
}else{
|
|
$shopInfo[$key]['expireday'] = $this->toMsg($expireDay);
|
|
}
|
|
}
|
|
if(count($shopInfo)>0){
|
|
return $shopInfo;
|
|
}else{
|
|
return array();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取session过期时间
|
|
*
|
|
* @param array
|
|
* @return void
|
|
* @author
|
|
**/
|
|
public function getSessionDays($shop)
|
|
{
|
|
$addon = $shop['addon'];
|
|
if(isset($addon['session_expire_time']) && $addon['session_expire_time']){
|
|
$session_expire_time = strtotime($addon['session_expire_time']);
|
|
$expire_time = $session_expire_time - time();
|
|
$expireDay = ceil($expire_time/86400);
|
|
}else{
|
|
$expireDay='no_expire_time';
|
|
}
|
|
return $expireDay;
|
|
}
|
|
/**
|
|
* @根据服务日期期限显示相应的提示信息
|
|
* @access public
|
|
* @param int $days 剩余的使用天数
|
|
* @return void
|
|
*/
|
|
private function toMsg($days) {
|
|
if($days === 0) {
|
|
$msg = '最后一天,请及时续约';
|
|
} elseif($days < 0) {
|
|
$msg = '已过期'. abs($days) . '天';
|
|
} else {
|
|
$msg = '还有'. $days .'天到期';
|
|
}
|
|
return $msg;
|
|
}
|
|
|
|
} |