在线升级与关系链修复仅超管可用
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
namespace app\admin\controller;
|
||||
|
||||
|
||||
use app\api\logic\DistributionLogic;
|
||||
use app\admin\logic\UpgradeLogic;
|
||||
|
||||
/** 升级更新
|
||||
@@ -37,6 +38,7 @@ class Upgrade extends AdminBase
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->checkSuperAdmin();
|
||||
if ($this->request->isAjax()) {
|
||||
$page = $this->request->get('page', $this->page_no);
|
||||
$size = $this->request->get('limit', $this->page_size);
|
||||
@@ -53,6 +55,7 @@ class Upgrade extends AdminBase
|
||||
*/
|
||||
public function choosePage()
|
||||
{
|
||||
$this->checkSuperAdmin();
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
@@ -63,6 +66,7 @@ class Upgrade extends AdminBase
|
||||
*/
|
||||
public function handleUpgrade()
|
||||
{
|
||||
$this->checkSuperAdmin();
|
||||
if ($this->request->isAjax()) {
|
||||
$post = $this->request->post();
|
||||
$post['update_type'] = 1;
|
||||
@@ -84,6 +88,7 @@ class Upgrade extends AdminBase
|
||||
// 下载更新包更新
|
||||
public function addUpdatePkgLog()
|
||||
{
|
||||
$this->checkSuperAdmin();
|
||||
$post = $this->request->post();
|
||||
$res = UpgradeLogic::getPkgLine($post);
|
||||
if(false === $res) {
|
||||
@@ -91,4 +96,27 @@ class Upgrade extends AdminBase
|
||||
}
|
||||
$this->_success('', $res);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 修复旧的关系链(仅超级管理员)
|
||||
*/
|
||||
public function fixAncestorRelation()
|
||||
{
|
||||
$this->checkSuperAdmin();
|
||||
$result = DistributionLogic::fixAncestorRelation();
|
||||
if (!empty($result['flag'])) {
|
||||
$this->_success(!empty($result['msg']) ? $result['msg'] : '修复成功');
|
||||
}
|
||||
$this->_error(!empty($result['msg']) ? $result['msg'] : '修复失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 系统更新相关操作仅超级管理员可用
|
||||
*/
|
||||
private function checkSuperAdmin()
|
||||
{
|
||||
if ((int)session('admin_info.id') !== 1) {
|
||||
$this->_error('无权限操作');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<p>* <font class="doc">更新至v2.6.3版本后,请执行 www.example.com/admin/distribution_center/updateTable, www.example.com为你的域名。</font></p>
|
||||
<p>* <font class="doc">更新至v2.6.3版本后,商品分销比例需在分销应用-分销-分销商品单独设置。</font></p>
|
||||
<p>* <font class="doc">更新至v2.6.4版本后,请执行 www.example.com/admin/distribution_order_goods/processOldData, www.example.com为你的域名。</font></p>
|
||||
<p>* <font class="doc">更新至v2.6.5版本后,请执行 www.example.com/api/distribution/fixAncestorRelation, www.example.com为你的域名。</font></p>
|
||||
<p>* <font class="doc">更新至v2.6.5版本后,请执行 www.example.com/admin/upgrade/fixAncestorRelation, www.example.com为你的域名。</font></p>
|
||||
<p>* <font class="doc">更新至v2.6.9版本后,地图更换为腾讯地图,请重新设置地图配置(设置->地图设置->腾讯地图设置)及自提门店地图定位(应用->自提门店)。</font></p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -242,4 +242,4 @@
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -26,7 +26,7 @@ use app\common\model\User;
|
||||
|
||||
class Distribution extends ApiBase
|
||||
{
|
||||
public $like_not_need_login = ['fixAncestorRelation'];
|
||||
public $like_not_need_login = [];
|
||||
/**
|
||||
* 填写邀请码
|
||||
*/
|
||||
@@ -149,19 +149,6 @@ class Distribution extends ApiBase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修复旧的关系链
|
||||
*/
|
||||
public function fixAncestorRelation()
|
||||
{
|
||||
$result = DistributionLogic::fixAncestorRelation();
|
||||
if ($result['flag']) {
|
||||
$this->_success($result['msg']);
|
||||
}
|
||||
$this->_error($result['msg']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取背景海报
|
||||
* @return Json
|
||||
@@ -173,4 +160,4 @@ class Distribution extends ApiBase
|
||||
$result = DistributionLogic::getPoster();
|
||||
$this->_success('',$result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ use app\common\model\{AccountLog, AfterSale, DistributionOrder, NoticeSetting, O
|
||||
use app\common\server\{AreaServer, ConfigServer, UrlServer};
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Hook;
|
||||
|
||||
class DistributionLogic
|
||||
@@ -572,6 +573,14 @@ class DistributionLogic
|
||||
|
||||
public static function fixAncestorRelation()
|
||||
{
|
||||
$lock_key = 'distribution_fix_ancestor_relation_lock';
|
||||
if (Cache::get($lock_key)) {
|
||||
return [
|
||||
"flag" => false,
|
||||
"msg" => '修复任务正在执行中'
|
||||
];
|
||||
}
|
||||
Cache::set($lock_key, 1, 60);
|
||||
Db::startTrans();
|
||||
try {
|
||||
$userList = User::select()->toArray();
|
||||
@@ -592,12 +601,14 @@ class DistributionLogic
|
||||
(new User())->saveAll($updateData);
|
||||
|
||||
Db::commit();
|
||||
Cache::rm($lock_key);
|
||||
return [
|
||||
"flag" => true,
|
||||
"msg" => '修复成功'
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Cache::rm($lock_key);
|
||||
return [
|
||||
"flag" => false,
|
||||
"msg" => $e->getMessage()
|
||||
@@ -614,18 +625,22 @@ class DistributionLogic
|
||||
return trim(self::findAncestorRelation($user['first_leader']), ',');
|
||||
}
|
||||
|
||||
public static function findAncestorRelation($id, $flag = true)
|
||||
public static function findAncestorRelation($id, $flag = true, $depth = 0)
|
||||
{
|
||||
static $ancestor_relation = '';
|
||||
if ($flag) {
|
||||
$ancestor_relation = '';
|
||||
}
|
||||
// 防止坏数据导致的循环递归
|
||||
if ($depth > 100) {
|
||||
return $ancestor_relation;
|
||||
}
|
||||
$ancestor_relation .= $id . ',';
|
||||
$user = User::findOrEmpty($id)->toArray();
|
||||
if (empty($user['first_leader'])) {
|
||||
return $ancestor_relation;
|
||||
}
|
||||
return self::findAncestorRelation($user['first_leader'], false);
|
||||
return self::findAncestorRelation($user['first_leader'], false, $depth + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -639,4 +654,4 @@ class DistributionLogic
|
||||
$poster = empty($poster) ? $poster : UrlServer::getFileUrl($poster);
|
||||
return ['poster'=>$poster];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user